Hi,
I'm using ACE framework, but I'll try to describe my problem without referencing to it.
I have an event handler (class derived from ACE_Event_Handler). Reference to the event handler is hold by some manager class in maps of shared_ptr's.
At some point of time I want to:
- remove the event handler from manager map
- Some method of event handler should be called by 3rd class which holds row pointer to the event handler (for those familiar with ACE it's handle_close() called by ACE Reactor)
The problem is that order (1) and (2) is not promised. If (1) is called before (2), (2) will work on dangling event handler.
So I thought about adding some additional reference to event handler that will be decremented in (2).
How it can be done? Can the reference to event handler be maintained from within the event handler itself (probably using enable_shared_from_this)?
Thanks