Inheritance diagram for ACE_Proactor_Timer_Handler:


Public Methods | |
| ACE_Proactor_Timer_Handler (ACE_Proactor &proactor) | |
| Constructor. More... | |
| virtual | ~ACE_Proactor_Timer_Handler (void) |
| Destructor. More... | |
| int | destroy (void) |
| Proactor calls this to shut down the timer handler gracefully. Just calling the destructor alone doesnt do what <destroy> does. <destroy> make sure the thread exits properly. More... | |
Protected Methods | |
| virtual int | svc (void) |
| Run by a daemon thread to handle deferred processing. In other words, this method will do the waiting on the earliest timer and event. More... | |
Protected Attributes | |
| ACE_Auto_Event | timer_event_ |
| Event to wait on. More... | |
| ACE_Proactor & | proactor_ |
| Proactor. More... | |
| int | shutting_down_ |
| Flag used to indicate when we are shutting down. More... | |
Friends | |
| class | ACE_Proactor |
| Proactor has special privileges Access needed to: timer_event_. More... | |
This object has a thread that will wait on the earliest time in a list of timers and an event. When a timer expires, the thread will post a completion event on the port and go back to waiting on the timer queue and event. If the event is signaled, the thread will refresh the time it is currently waiting on (in case the earliest time has changed).
Definition at line 52 of file Proactor.cpp.
|
|
Constructor.
Definition at line 87 of file Proactor.cpp.
00088 : ACE_Task <ACE_NULL_SYNCH> (&proactor.thr_mgr_), 00089 proactor_ (proactor), 00090 shutting_down_ (0) 00091 { 00092 } |
|
|
Destructor.
Definition at line 94 of file Proactor.cpp. References shutting_down_, ACE_Event::signal, ACE_Task_Base::thr_mgr, timer_event_, and ACE_Thread_Manager::wait_grp.
00095 {
00096 // Mark for closing down.
00097 this->shutting_down_ = 1;
00098
00099 // Signal timer event.
00100 this->timer_event_.signal ();
00101
00102 // Wait for the Timer Handler thread to exit.
00103 this->thr_mgr ()->wait_grp (this->grp_id ());
00104 }
|
|
|
Proactor calls this to shut down the timer handler gracefully. Just calling the destructor alone doesnt do what <destroy> does. <destroy> make sure the thread exits properly.
|
|
|
Run by a daemon thread to handle deferred processing. In other words, this method will do the waiting on the earliest timer and event.
Reimplemented from ACE_Task_Base. Definition at line 107 of file Proactor.cpp. References ACE_ERROR_RETURN, ACE_LIB_TEXT, ETIME, LM_ERROR, proactor_, shutting_down_, timer_event_, ACE_Proactor::timer_queue, and ACE_Event::wait.
00108 {
00109 ACE_Time_Value absolute_time;
00110 ACE_Time_Value relative_time;
00111 int result = 0;
00112
00113 while (this->shutting_down_ == 0)
00114 {
00115 // Check whether the timer queue has any items in it.
00116 if (this->proactor_.timer_queue ()->is_empty () == 0)
00117 {
00118 // Get the earliest absolute time.
00119 absolute_time = this->proactor_.timer_queue ()->earliest_time ();
00120
00121 // Get current time from timer queue since we don't know
00122 // which <gettimeofday> was used.
00123 ACE_Time_Value cur_time = this->proactor_.timer_queue ()->gettimeofday ();
00124
00125 // Compare absolute time with curent time received from the
00126 // timer queue.
00127 if (absolute_time > cur_time)
00128 relative_time = absolute_time - cur_time;
00129 else
00130 relative_time = 0;
00131
00132 // Block for relative time.
00133 result = this->timer_event_.wait (&relative_time, 0);
00134 }
00135 else
00136 // The timer queue has no entries, so wait indefinitely.
00137 result = this->timer_event_.wait ();
00138
00139 // Check for timer expiries.
00140 if (result == -1)
00141 {
00142 switch (errno)
00143 {
00144 case ETIME:
00145 // timeout: expire timers
00146 this->proactor_.timer_queue ()->expire ();
00147 break;
00148 default:
00149 // Error.
00150 ACE_ERROR_RETURN ((LM_ERROR,
00151 ACE_LIB_TEXT ("%N:%l:(%P | %t):%p\n"),
00152 ACE_LIB_TEXT ("ACE_Proactor_Timer_Handler::svc:wait failed")),
00153 -1);
00154 }
00155 }
00156 }
00157 return 0;
00158 }
|
|
|
Proactor has special privileges Access needed to: timer_event_.
Definition at line 57 of file Proactor.cpp. |
|
|
Proactor.
Definition at line 81 of file Proactor.cpp. Referenced by svc. |
|
|
Flag used to indicate when we are shutting down.
Definition at line 84 of file Proactor.cpp. Referenced by svc, and ~ACE_Proactor_Timer_Handler. |
|
|
Event to wait on.
Definition at line 78 of file Proactor.cpp. Referenced by ACE_Proactor::schedule_timer, svc, and ~ACE_Proactor_Timer_Handler. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002