#include <Dev_Poll_Reactor.h>
Collaboration diagram for ACE_Dev_Poll_Handler_Guard:
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_Handler * | eh_ |
The event handler being managed. | |
bool | refcounted_ |
true if eh_ is a reference-counted handler. |
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.
Definition at line 1235 of file Dev_Poll_Reactor.h.
|
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
Definition at line 101 of file Dev_Poll_Reactor.inl.
00103 : eh_ (eh), 00104 refcounted_ (false) 00105 { 00106 if (eh == 0) 00107 return; 00108 00109 this->refcounted_ = 00110 eh->reference_counting_policy ().value () == 00111 ACE_Event_Handler::Reference_Counting_Policy::ENABLED; 00112 00113 if (do_incr && this->refcounted_) 00114 eh->add_reference (); 00115 00116 /** 00117 * The below comments were here when I replaced the old refcount 00118 * scheme was replaced. They may still need addressing. -Steve Huston 00119 */ 00120 00121 /** 00122 * @todo Suspend the handler so that other threads will not cause 00123 * an event that is already in an upcall from being dispatched 00124 * again. 00125 * 00126 * @note The naive approach would be to simply call 00127 * suspend_handler_i() on the reactor. However, that would 00128 * cause a system call (write()) to occur. Obviously this 00129 * can potentially have an adverse affect on performance. 00130 * Ideally, the handler would only be marked as "suspended" in 00131 * the handler repository. If an event arrives for a 00132 * suspended handler that event can be "queued" in a 00133 * "handle readiness queue." "Queued" is quoted since a real 00134 * queue need not be used since duplicate events can be 00135 * coalesced, thus avoiding unbounded queue growth. Event 00136 * coalescing is already done by Linux's event poll driver 00137 * (/dev/epoll) so Solaris' poll driver (/dev/poll) is the 00138 * main concern here. The largest the queue can be is the 00139 * same size as the number of handlers stored in the handler 00140 * repository. 00141 */ 00142 } |
|
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
Definition at line 145 of file Dev_Poll_Reactor.inl. References eh_, refcounted_, and ACE_Event_Handler::remove_reference().
00146 { 00147 if (this->refcounted_ && this->eh_ != 0) 00148 this->eh_->remove_reference (); 00149 00150 /** 00151 * The below comments were here when I replaced the old refcount 00152 * scheme was replaced. They may still need addressing. -Steve Huston 00153 */ 00154 /** 00155 * @todo Resume the handler so that other threads will be allowed to 00156 * dispatch the handler. 00157 */ 00158 } |
|
Release the event handler from this guard; when the destructor is called, the handler's reference count will not be decremented. Definition at line 161 of file Dev_Poll_Reactor.inl. References eh_. Referenced by ACE_Dev_Poll_Reactor_Notify::notify().
00162 { 00163 this->eh_ = 0; 00164 } |
|
The event handler being managed.
Definition at line 1264 of file Dev_Poll_Reactor.h. Referenced by release(), and ~ACE_Dev_Poll_Handler_Guard(). |
|
true if eh_ is a reference-counted handler.
Definition at line 1267 of file Dev_Poll_Reactor.h. Referenced by ~ACE_Dev_Poll_Handler_Guard(). |