Our (Windows native C ++) application consists of stream objects and managers. It is fairly well written, with a design that sees Manager objects that manage the life cycle of their minions. Various objects for sending and receiving events; some events come from Windows, some of them are home-based.
In general, we should be very aware of the interaction of threads, so we use manual synchronization technologies using critical Win32 partitions, semaphores, etc. However, sometimes we encounter a shutter deadlock during a shutdown due to things like event handler forwarding.
Now I wonder if there is a decent application closure strategy that we could implement to make it easier to develop - something like any object that logs a shutdown event from the central controller and changes its execution behavior accordingly? Is it too naive or fragile?
I would prefer strategies that do not rewrite the entire application in order to use the Microsoft parallel template library or similar .; -)
Thanks.
EDIT:
I assume that I am asking for an approach to managing the life cycles of objects in a complex application, where many threads and events are constantly triggered. Giovanni's suggestion is obvious (our manual work), but I am convinced that there should be various ready-made strategies or frameworks for cleanly closing active objects in the correct order. For example, if you want to create your own C ++ application in the IoC paradigm, you can use the PocoCapsule instead of trying to develop your own container. Is there something similar for managing the life cycles of an object in an application?
source share