#include <XtReactor.h>
Inheritance diagram for ACE_XtReactor:
Public Member Functions | |
ACE_XtReactor (XtAppContext context=0, size_t size=DEFAULT_SIZE, int restart=0, ACE_Sig_Handler *=0) | |
virtual | ~ACE_XtReactor (void) |
XtAppContext | context (void) const |
void | context (XtAppContext) |
virtual long | schedule_timer (ACE_Event_Handler *event_handler, const void *arg, const ACE_Time_Value &delay, const ACE_Time_Value &interval) |
virtual int | reset_timer_interval (long timer_id, const ACE_Time_Value &interval) |
virtual int | cancel_timer (ACE_Event_Handler *handler, int dont_call_handle_close=1) |
virtual int | cancel_timer (long timer_id, const void **arg=0, int dont_call_handle_close=1) |
Protected Member Functions | |
virtual int | register_handler_i (ACE_HANDLE handle, ACE_Event_Handler *handler, ACE_Reactor_Mask mask) |
Register a single . | |
virtual int | register_handler_i (const ACE_Handle_Set &handles, ACE_Event_Handler *handler, ACE_Reactor_Mask mask) |
Register a set of . | |
virtual int | remove_handler_i (ACE_HANDLE handle, ACE_Reactor_Mask mask) |
Remove the associated with this . | |
virtual int | remove_handler_i (const ACE_Handle_Set &handles, ACE_Reactor_Mask) |
Remove a set of . | |
virtual void | remove_XtInput (ACE_HANDLE handle) |
Removes an Xt handle. | |
virtual int | wait_for_multiple_events (ACE_Select_Reactor_Handle_Set &, ACE_Time_Value *) |
Wait for events to occur. | |
virtual int | XtWaitForMultipleEvents (int, ACE_Select_Reactor_Handle_Set &, ACE_Time_Value *) |
Wait for Xt events to occur. | |
Protected Attributes | |
XtAppContext | context_ |
ACE_XtReactorID * | ids_ |
XtIntervalId | timeout_ |
Private Member Functions | |
void | reset_timeout (void) |
ACE_XtReactor (const ACE_XtReactor &) | |
Deny access since member-wise won't work... | |
ACE_XtReactor & | operator= (const ACE_XtReactor &) |
Static Private Member Functions | |
void | TimerCallbackProc (XtPointer closure, XtIntervalId *id) |
void | InputCallbackProc (XtPointer closure, int *source, XtInputId *id) |
Definition at line 59 of file XtReactor.h.
|
Definition at line 15 of file XtReactor.cpp. References ACE_Select_Reactor, ACE_Reactor_Notify::close(), and ACE_Reactor_Notify::open().
00019 : ACE_Select_Reactor (size, restart, h), 00020 context_ (context), 00021 ids_ (0), 00022 timeout_ (0) 00023 { 00024 // When the ACE_Select_Reactor is constructed it creates the notify 00025 // pipe and registers it with the register_handler_i() method. The 00026 // XtReactor overloads this method BUT because the 00027 // register_handler_i occurs when constructing the base class 00028 // ACE_Select_Reactor, the ACE_Select_Reactor register_handler_i() 00029 // is called not the XtReactor register_handler_i(). This means 00030 // that the notify pipe is registered with the ACE_Select_Reactor 00031 // event handling code not the XtReactor and so notfications don't 00032 // work. To get around this we simply close and re-opened the 00033 // notification handler in the constructor of the XtReactor. 00034 00035 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) 00036 this->notify_handler_->close (); 00037 this->notify_handler_->open (this, 0); 00038 #endif /* ACE_MT_SAFE */ 00039 } |
|
Definition at line 41 of file XtReactor.cpp. References ACE_XtReactorID::next_.
|
|
Deny access since member-wise won't work...
|
|
Cancel the single ACE_Event_Handler that matches the value (which was returned from the method). If arg is non-NULL then it will be set to point to the ``magic cookie'' argument passed in when the was registered. This makes it possible to free up the memory and avoid memory leaks. If is 0 then the method of will be invoked. Returns 1 if cancellation succeeded and 0 if the wasn't found. Reimplemented from ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >. Definition at line 433 of file XtReactor.cpp. References ACE_TRACE, ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::cancel_timer(), and reset_timeout().
00436 { 00437 ACE_TRACE ("ACE_XtReactor::cancel_timer"); 00438 00439 if (ACE_Select_Reactor::cancel_timer (timer_id, 00440 arg, 00441 dont_call_handle_close) == -1) 00442 return -1; 00443 else 00444 { 00445 this->reset_timeout (); 00446 return 0; 00447 } 00448 } |
|
Cancel all that match the address of . If is 0 then the method of will be invoked. Returns number of handler's cancelled. Reimplemented from ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >. Definition at line 417 of file XtReactor.cpp. References ACE_TRACE, ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::cancel_timer(), and reset_timeout().
00419 { 00420 ACE_TRACE ("ACE_XtReactor::cancel_timer"); 00421 00422 if (ACE_Select_Reactor::cancel_timer (handler, 00423 dont_call_handle_close) == -1) 00424 return -1; 00425 else 00426 { 00427 this->reset_timeout (); 00428 return 0; 00429 } 00430 } |
|
Definition at line 191 of file XtReactor.cpp.
00192 { 00193 this->context_ = context; 00194 } |
|
Definition at line 185 of file XtReactor.cpp.
00186 { 00187 return this->context_; 00188 } |
|
Definition at line 105 of file XtReactor.cpp. References ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::dispatch(), ACE_Select_Reactor_Handle_Set::ex_mask_, ACE_Handle_Set::is_set(), ACE_Select_Reactor_Handle_Set::rd_mask_, ACE_OS::select(), ACE_Handle_Set::set_bit(), ACE_Select_Reactor_Impl::wait_set_, and ACE_Select_Reactor_Handle_Set::wr_mask_.
00108 { 00109 ACE_XtReactor *self = (ACE_XtReactor *) closure; 00110 ACE_HANDLE handle = (ACE_HANDLE) *source; 00111 00112 // my copy isn't const. 00113 ACE_Time_Value zero = ACE_Time_Value::zero; 00114 00115 ACE_Select_Reactor_Handle_Set wait_set; 00116 00117 // Deal with one file event. 00118 00119 // - read which kind of event 00120 if (self->wait_set_.rd_mask_.is_set (handle)) 00121 wait_set.rd_mask_.set_bit (handle); 00122 if (self->wait_set_.wr_mask_.is_set (handle)) 00123 wait_set.wr_mask_.set_bit (handle); 00124 if (self->wait_set_.ex_mask_.is_set (handle)) 00125 wait_set.ex_mask_.set_bit (handle); 00126 00127 int result = ACE_OS::select (*source + 1, 00128 wait_set.rd_mask_, 00129 wait_set.wr_mask_, 00130 wait_set.ex_mask_, &zero); 00131 00132 ACE_Select_Reactor_Handle_Set dispatch_set; 00133 00134 // - Use only that one file event (removes events for other files). 00135 if (result > 0) 00136 { 00137 if (wait_set.rd_mask_.is_set (handle)) 00138 dispatch_set.rd_mask_.set_bit (handle); 00139 if (wait_set.wr_mask_.is_set (handle)) 00140 dispatch_set.wr_mask_.set_bit (handle); 00141 if (wait_set.ex_mask_.is_set (handle)) 00142 dispatch_set.ex_mask_.set_bit (handle); 00143 00144 self->dispatch (1, dispatch_set); 00145 } 00146 } |
|
|
|
Register a set of .
Reimplemented from ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >. Definition at line 278 of file XtReactor.cpp. References ACE_Reactor_Mask, and ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::register_handler_i().
00281 { 00282 return ACE_Select_Reactor::register_handler_i (handles, 00283 handler, 00284 mask); 00285 } |
|
Register a single .
Reimplemented from ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >. Definition at line 197 of file XtReactor.cpp. References ACE_ASSERT, ACE_BIT_ENABLED, ACE_NEW_RETURN, ACE_NOTSUP_RETURN, ACE_Reactor_Mask, ACE_SET_BITS, ACE_TRACE, ACE_XtReactorID::handle_, ACE_XtReactorID::id_, ACE_XtReactorID::next_, and ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::register_handler_i().
00200 { 00201 ACE_TRACE ("ACE_XtReactor::register_handler_i"); 00202 00203 // Make sure we have a valid context 00204 ACE_ASSERT (this->context_ != 0); 00205 00206 int result = ACE_Select_Reactor::register_handler_i (handle, 00207 handler, mask); 00208 if (result == -1) 00209 return -1; 00210 00211 int condition = 0; 00212 00213 #if !defined ACE_WIN32 00214 if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK)) 00215 ACE_SET_BITS (condition, XtInputReadMask); 00216 if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK)) 00217 ACE_SET_BITS (condition, XtInputWriteMask); 00218 if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK)) 00219 ACE_SET_BITS (condition, XtInputExceptMask); 00220 if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK)) 00221 ACE_SET_BITS (condition, XtInputReadMask); 00222 if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK)){ 00223 ACE_SET_BITS (condition, XtInputWriteMask); // connected, you may write 00224 ACE_SET_BITS (condition, XtInputReadMask); // connected, you have data/err 00225 } 00226 #else 00227 if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK)) 00228 ACE_SET_BITS (condition, XtInputReadWinsock); 00229 if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK)) 00230 ACE_SET_BITS (condition, XtInputWriteWinsock); 00231 if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK)) 00232 ACE_NOTSUP_RETURN(-1); 00233 if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK)) 00234 ACE_SET_BITS (condition, XtInputReadWinsock); 00235 if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK)){ 00236 ACE_SET_BITS (condition, XtInputWriteWinsock); // connected, you may write 00237 ACE_SET_BITS (condition, XtInputReadWinsock); // connected, you have data/err 00238 } 00239 #endif /* !ACE_WIN32 */ 00240 00241 if (condition != 0) 00242 { 00243 ACE_XtReactorID *XtID = this->ids_; 00244 00245 while(XtID) 00246 { 00247 if (XtID->handle_ == handle) 00248 { 00249 ::XtRemoveInput (XtID->id_); 00250 00251 XtID->id_ = ::XtAppAddInput (this->context_, 00252 (int) handle, 00253 (XtPointer) condition, 00254 InputCallbackProc, 00255 (XtPointer) this); 00256 return 0; 00257 } 00258 else 00259 XtID = XtID->next_; 00260 } 00261 00262 ACE_NEW_RETURN (XtID, 00263 ACE_XtReactorID, 00264 -1); 00265 XtID->next_ = this->ids_; 00266 XtID->handle_ = handle; 00267 XtID->id_ = ::XtAppAddInput (this->context_, 00268 (int) handle, 00269 (XtPointer) condition, 00270 InputCallbackProc, 00271 (XtPointer) this); 00272 this->ids_ = XtID; 00273 } 00274 return 0; 00275 } |
|
Remove a set of .
Reimplemented from ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >. Definition at line 343 of file XtReactor.cpp. References ACE_Reactor_Mask, and ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::remove_handler_i().
00345 { 00346 return ACE_Select_Reactor::remove_handler_i (handles, 00347 mask); 00348 } |
|
Remove the associated with this .
Reimplemented from ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >. Definition at line 288 of file XtReactor.cpp. References ACE_Reactor_Mask, ACE_TRACE, ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::remove_handler_i(), and remove_XtInput().
00290 { 00291 ACE_TRACE ("ACE_XtReactor::remove_handler_i"); 00292 00293 // In the registration phase we registered first with 00294 // ACE_Select_Reactor and then with X. Now we are now doing things 00295 // in reverse order. 00296 00297 // First clean up the corresponding X11Input. 00298 this->remove_XtInput (handle); 00299 00300 // Now let the reactor do its work. 00301 return ACE_Select_Reactor::remove_handler_i (handle, 00302 mask); 00303 } |
|
Removes an Xt handle.
Definition at line 306 of file XtReactor.cpp. References ACE_TRACE, ACE_XtReactorID::handle_, ACE_XtReactorID::id_, and ACE_XtReactorID::next_. Referenced by remove_handler_i().
00307 { 00308 ACE_TRACE ("ACE_XtReactor::remove_XtInput"); 00309 00310 ACE_XtReactorID *XtID = this->ids_; 00311 00312 if (XtID) 00313 { 00314 if (XtID->handle_ == handle) 00315 { 00316 ::XtRemoveInput (XtID->id_); 00317 this->ids_ = XtID->next_; 00318 delete XtID; 00319 return; 00320 } 00321 00322 ACE_XtReactorID *NextID = XtID->next_; 00323 00324 while (NextID) 00325 { 00326 if (NextID->handle_ == handle) 00327 { 00328 ::XtRemoveInput(NextID->id_); 00329 XtID->next_ = NextID->next_; 00330 delete NextID; 00331 return; 00332 } 00333 else 00334 { 00335 XtID = NextID; 00336 NextID = NextID->next_; 00337 } 00338 } 00339 } 00340 } |
|
This method ensures there's an Xt timeout for the first timeout in the Reactor's Timer_Queue. Definition at line 354 of file XtReactor.cpp. References ACE_ASSERT, ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK >::calculate_timeout(), and ACE_Time_Value::msec(). Referenced by cancel_timer(), schedule_timer(), and TimerCallbackProc().
00355 { 00356 // Make sure we have a valid context 00357 ACE_ASSERT (this->context_ != 0); 00358 00359 if (timeout_) 00360 ::XtRemoveTimeOut (timeout_); 00361 timeout_ = 0; 00362 00363 ACE_Time_Value *max_wait_time = 00364 this->timer_queue_->calculate_timeout (0); 00365 00366 if (max_wait_time) 00367 timeout_ = ::XtAppAddTimeOut (this->context_, 00368 max_wait_time->msec (), 00369 TimerCallbackProc, 00370 (XtPointer) this); 00371 } |
|
Resets the interval of the timer represented by to , which is specified in relative time to the current . If is equal to <ACE_Time_Value::zero>, the timer will become a non-rescheduling timer. Returns 0 if successful, -1 if not. Reimplemented from ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >. Definition at line 375 of file XtReactor.cpp. References ACE_GUARD_RETURN, ACE_Select_Reactor_Token, and ACE_TRACE.
00377 { 00378 ACE_TRACE ("ACE_XtReactor::reset_timer_interval"); 00379 ACE_MT (ACE_GUARD_RETURN (ACE_Select_Reactor_Token, ace_mon, this->token_, -1)); 00380 00381 int const result = ACE_Select_Reactor::timer_queue_->reset_interval 00382 (timer_id, 00383 interval); 00384 00385 if (result == -1) 00386 return -1; 00387 else 00388 { 00389 this->reset_timeout (); 00390 return result; 00391 } 00392 } |
|
Schedule an ACE_Event_Handler that will expire after an amount of time. The return value of this method, a timer_id value, uniquely identifies the event_handler in the ACE_Reactor's internal list of timers. This timer_id value can be used to cancel the timer with the cancel_timer() call.
Reimplemented from ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >. Definition at line 395 of file XtReactor.cpp. References ACE_GUARD_RETURN, ACE_Select_Reactor_Token, ACE_TRACE, reset_timeout(), and ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::schedule_timer().
00399 { 00400 ACE_TRACE ("ACE_XtReactor::schedule_timer"); 00401 ACE_MT (ACE_GUARD_RETURN (ACE_Select_Reactor_Token, ace_mon, this->token_, -1)); 00402 00403 long const result = ACE_Select_Reactor::schedule_timer (event_handler, 00404 arg, 00405 delay, 00406 interval); 00407 if (result == -1) 00408 return -1; 00409 else 00410 { 00411 this->reset_timeout (); 00412 return result; 00413 } 00414 } |
|
Definition at line 89 of file XtReactor.cpp. References ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::dispatch(), reset_timeout(), and timeout_.
00090 { 00091 ACE_XtReactor *self = (ACE_XtReactor *) closure; 00092 self->timeout_ = 0; 00093 00094 // Deal with any timer events 00095 ACE_Select_Reactor_Handle_Set handle_set; 00096 self->dispatch (0, handle_set); 00097 self->reset_timeout (); 00098 } |
|
Wait for events to occur.
Reimplemented from ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >. Definition at line 57 of file XtReactor.cpp. References ACE_TRACE, ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK >::calculate_timeout(), ACE_Select_Reactor_Handle_Set::ex_mask_, ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::handle_error(), ACE_Select_Reactor_Handler_Repository::max_handlep1(), ACE_Select_Reactor_Handle_Set::rd_mask_, ACE_Handle_Set::sync(), ACE_Select_Reactor_Handle_Set::wr_mask_, and XtWaitForMultipleEvents().
00059 { 00060 ACE_TRACE ("ACE_XtReactor::wait_for_multiple_events"); 00061 int nfound; 00062 00063 do 00064 { 00065 max_wait_time = this->timer_queue_->calculate_timeout (max_wait_time); 00066 00067 size_t width = this->handler_rep_.max_handlep1 (); 00068 handle_set.rd_mask_ = this->wait_set_.rd_mask_; 00069 handle_set.wr_mask_ = this->wait_set_.wr_mask_; 00070 handle_set.ex_mask_ = this->wait_set_.ex_mask_; 00071 nfound = XtWaitForMultipleEvents (width, 00072 handle_set, 00073 max_wait_time); 00074 00075 } while (nfound == -1 && this->handle_error () > 0); 00076 00077 if (nfound > 0) 00078 { 00079 #if !defined (ACE_WIN32) 00080 handle_set.rd_mask_.sync (this->handler_rep_.max_handlep1 ()); 00081 handle_set.wr_mask_.sync (this->handler_rep_.max_handlep1 ()); 00082 handle_set.ex_mask_.sync (this->handler_rep_.max_handlep1 ()); 00083 #endif /* ACE_WIN32 */ 00084 } 00085 return nfound; // Timed out or input available 00086 } |
|
Wait for Xt events to occur.
Definition at line 149 of file XtReactor.cpp. References ACE_ASSERT, ACE_Select_Reactor_Handle_Set::ex_mask_, ACE_Select_Reactor_Handler_Repository::max_handlep1(), ACE_Select_Reactor_Handle_Set::rd_mask_, ACE_OS::select(), and ACE_Select_Reactor_Handle_Set::wr_mask_. Referenced by wait_for_multiple_events().
00152 { 00153 // Make sure we have a valid context 00154 ACE_ASSERT (this->context_ != 0); 00155 00156 // Check to make sure our handle's are all usable. 00157 ACE_Select_Reactor_Handle_Set temp_set = wait_set; 00158 00159 if (ACE_OS::select (width, 00160 temp_set.rd_mask_, 00161 temp_set.wr_mask_, 00162 temp_set.ex_mask_, 00163 (ACE_Time_Value *) &ACE_Time_Value::zero) == -1) 00164 return -1; // Bad file arguments... 00165 00166 // Instead of waiting using <select>, just use the Xt mechanism to 00167 // wait for a single event. 00168 00169 // Wait for something to happen. 00170 ::XtAppProcessEvent (this->context_, XtIMAll); 00171 00172 // Reset the width, in case it changed during the upcalls. 00173 width = this->handler_rep_.max_handlep1 (); 00174 00175 // Now actually read the result needed by the <Select_Reactor> using 00176 // <select>. 00177 return ACE_OS::select (width, 00178 wait_set.rd_mask_, 00179 wait_set.wr_mask_, 00180 wait_set.ex_mask_, 00181 (ACE_Time_Value *) &ACE_Time_Value::zero); 00182 } |
|
Definition at line 118 of file XtReactor.h. |
|
Definition at line 119 of file XtReactor.h. |
|
Definition at line 120 of file XtReactor.h. Referenced by TimerCallbackProc(). |