ACE_Dev_Poll_Handler_Guard Class Reference

Class used to make event handler reference count manipulation exception-safe. More...

#include <Dev_Poll_Reactor.h>

Collaboration diagram for ACE_Dev_Poll_Handler_Guard:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ACE_Dev_Poll_Handler_Guard (ACE_Event_Handler *eh, bool do_incr=true)
 Constructor.
 ~ACE_Dev_Poll_Handler_Guard (void)
 Destructor.
void release (void)

Private Attributes

ACE_Event_Handlereh_
 The event handler being managed.
bool refcounted_
 true if eh_ is a reference-counted handler.

Detailed Description

Class used to make event handler reference count manipulation exception-safe.

This class makes the reference count manipulation that occurs during an upcall exception-safe. Prior to dispatching the event handler, the reference count is increased. Once the upcall for the given event handler is complete, its reference count will be decreased.


Constructor & Destructor Documentation

ACE_Dev_Poll_Handler_Guard::ACE_Dev_Poll_Handler_Guard ( ACE_Event_Handler eh,
bool  do_incr = true 
)

Constructor.

The constructor checks to see if eh is a reference-counted handler and remember that for later. If eh is reference counted, its reference count is incremented unless do_incr is false. do_incr should be false if the reference count was incremented independently of this guard, for example, on a notify handler since the reference count is incremented when the notify is queued.

The below comments were here when I replaced the old refcount scheme was replaced. They may still need addressing. -Steve Huston

Todo:
Suspend the handler so that other threads will not cause an event that is already in an upcall from being dispatched again.
Note:
The naive approach would be to simply call suspend_handler_i() on the reactor. However, that would cause a system call (write()) to occur. Obviously this can potentially have an adverse affect on performance. Ideally, the handler would only be marked as "suspended" in the handler repository. If an event arrives for a suspended handler that event can be "queued" in a "handle readiness queue." "Queued" is quoted since a real queue need not be used since duplicate events can be coalesced, thus avoiding unbounded queue growth. Event coalescing is already done by Linux's event poll driver (/dev/epoll) so Solaris' poll driver (/dev/poll) is the main concern here. The largest the queue can be is the same size as the number of handlers stored in the handler repository.

ACE_Dev_Poll_Handler_Guard::~ACE_Dev_Poll_Handler_Guard ( void   ) 

Destructor.

The destructor decrements the reference count on the event handler corresponding to the given handle.

The below comments were here when I replaced the old refcount scheme was replaced. They may still need addressing. -Steve Huston

Todo:
Resume the handler so that other threads will be allowed to dispatch the handler.


Member Function Documentation

void ACE_Dev_Poll_Handler_Guard::release ( void   ) 

Release the event handler from this guard; when the destructor is called, the handler's reference count will not be decremented.


Member Data Documentation

The event handler being managed.

true if eh_ is a reference-counted handler.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Mon Nov 30 00:51:49 2009 for ACE by  doxygen 1.6.1