Inheritance diagram for ACE_Proactor_Timer_Handler:


| Public Member Functions | |
| ACE_Proactor_Timer_Handler (ACE_Proactor &proactor) | |
| Constructor. | |
| virtual | ~ACE_Proactor_Timer_Handler (void) | 
| Destructor. | |
| int | destroy (void) | 
| Protected Member Functions | |
| virtual int | svc (void) | 
| Protected Attributes | |
| ACE_Auto_Event | timer_event_ | 
| Event to wait on. | |
| ACE_Proactor & | proactor_ | 
| Proactor. | |
| int | shutting_down_ | 
| Flag used to indicate when we are shutting down. | |
| Friends | |
| class | ACE_Proactor | 
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 63 of file Proactor.cpp.
| 
 | 
| Constructor. 
 Definition at line 98 of file Proactor.cpp. 
 00099 : ACE_Task <ACE_NULL_SYNCH> (&proactor.thr_mgr_), 00100 proactor_ (proactor), 00101 shutting_down_ (0) 00102 { 00103 } | 
| 
 | 
| Destructor. 
 Definition at line 105 of file Proactor.cpp. References ACE_Event::signal(), ACE_Task_Base::thr_mgr(), timer_event_, and ACE_Thread_Manager::wait_grp(). 
 00106 {
00107   // Mark for closing down.
00108   this->shutting_down_ = 1;
00109 
00110   // Signal timer event.
00111   this->timer_event_.signal ();
00112 
00113   // Wait for the Timer Handler thread to exit.
00114   this->thr_mgr ()->wait_grp (this->grp_id ());
00115 }
 | 
| 
 | 
| Proactor calls this to shut down the timer handler gracefully. Just calling the destructor alone doesnt do what does. 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 118 of file Proactor.cpp. References ACE_ERROR_RETURN, ACE_LIB_TEXT, ETIME, LM_ERROR, timer_event_, ACE_Proactor::timer_queue(), and ACE_Event::wait(). 
 00119 {
00120   ACE_Time_Value absolute_time;
00121   ACE_Time_Value relative_time;
00122   int result = 0;
00123 
00124   while (this->shutting_down_ == 0)
00125     {
00126       // Check whether the timer queue has any items in it.
00127       if (this->proactor_.timer_queue ()->is_empty () == 0)
00128         {
00129           // Get the earliest absolute time.
00130           absolute_time = this->proactor_.timer_queue ()->earliest_time ();
00131 
00132           // Get current time from timer queue since we don't know
00133           // which <gettimeofday> was used.
00134           ACE_Time_Value cur_time = this->proactor_.timer_queue ()->gettimeofday ();
00135 
00136           // Compare absolute time with curent time received from the
00137           // timer queue.
00138           if (absolute_time > cur_time)
00139             relative_time = absolute_time - cur_time;
00140           else
00141             relative_time = ACE_Time_Value::zero;
00142 
00143           // Block for relative time.
00144           result = this->timer_event_.wait (&relative_time, 0);
00145         }
00146       else
00147         // The timer queue has no entries, so wait indefinitely.
00148         result = this->timer_event_.wait ();
00149 
00150       // Check for timer expiries.
00151       if (result == -1)
00152         {
00153           switch (errno)
00154             {
00155             case ETIME:
00156               // timeout: expire timers
00157               this->proactor_.timer_queue ()->expire ();
00158               break;
00159             default:
00160               // Error.
00161               ACE_ERROR_RETURN ((LM_ERROR,
00162                                  ACE_LIB_TEXT ("%N:%l:(%P | %t):%p\n"),
00163                                  ACE_LIB_TEXT ("ACE_Proactor_Timer_Handler::svc:wait failed")),
00164                                 -1);
00165             }
00166         }
00167     }
00168   return 0;
00169 }
 | 
| 
 | 
| Proactor has special privileges Access needed to: timer_event_ Definition at line 68 of file Proactor.cpp. | 
| 
 | 
| Proactor. 
 Definition at line 92 of file Proactor.cpp. | 
| 
 | 
| Flag used to indicate when we are shutting down. 
 Definition at line 95 of file Proactor.cpp. | 
| 
 | 
| Event to wait on. 
 Definition at line 89 of file Proactor.cpp. Referenced by ACE_Proactor::schedule_timer(), svc(), and ~ACE_Proactor_Timer_Handler(). | 
 1.3.6
 
1.3.6