Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_Proactor_Timer_Handler Class Reference

A Handler for timer. It helps in the management of timers registered with the Proactor. More...

Inheritance diagram for ACE_Proactor_Timer_Handler:

Inheritance graph
[legend]
Collaboration diagram for ACE_Proactor_Timer_Handler:

Collaboration graph
[legend]
List of all members.

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_Proactorproactor_
 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...


Detailed Description

A Handler for timer. It helps in the management of timers registered with the 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 52 of file Proactor.cpp.


Constructor & Destructor Documentation

ACE_Proactor_Timer_Handler::ACE_Proactor_Timer_Handler ACE_Proactor   proactor
 

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 }

ACE_Proactor_Timer_Handler::~ACE_Proactor_Timer_Handler void    [virtual]
 

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 }


Member Function Documentation

int ACE_Proactor_Timer_Handler::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.

int ACE_Proactor_Timer_Handler::svc void    [protected, virtual]
 

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 }


Friends And Related Function Documentation

friend class ACE_Proactor [friend]
 

Proactor has special privileges Access needed to: timer_event_.

Definition at line 57 of file Proactor.cpp.


Member Data Documentation

ACE_Proactor& ACE_Proactor_Timer_Handler::proactor_ [protected]
 

Proactor.

Definition at line 81 of file Proactor.cpp.

Referenced by svc.

int ACE_Proactor_Timer_Handler::shutting_down_ [protected]
 

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.

ACE_Auto_Event ACE_Proactor_Timer_Handler::timer_event_ [protected]
 

Event to wait on.

Definition at line 78 of file Proactor.cpp.

Referenced by ACE_Proactor::schedule_timer, svc, and ~ACE_Proactor_Timer_Handler.


The documentation for this class was generated from the following file:
Generated on Mon Jun 16 12:54:26 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002