#include <Timer_Queue_Adapters.h>
Inheritance diagram for ACE_Async_Timer_Queue_Adapter< TQ >:


Public Types | |
| typedef TQ | TIMER_QUEUE |
Public Member Functions | |
| ACE_Async_Timer_Queue_Adapter (ACE_Sig_Set *mask=0) | |
| Constructor. | |
| long | schedule (ACE_Event_Handler *type, const void *act, const ACE_Time_Value &future_time, const ACE_Time_Value &interval=ACE_Time_Value::zero) |
| int | cancel (long timer_id, const void **act=0) |
| int | expire (void) |
| TQ & | timer_queue (void) |
| Return a reference to the underlying timer queue. | |
Private Member Functions | |
| virtual int | schedule_ualarm (void) |
| Perform the logic to compute the new ualarm(2) setting. | |
| virtual int | handle_signal (int signum, siginfo_t *, ucontext_t *) |
Called back by SIGALRM handler. | |
Private Attributes | |
| ACE_Sig_Handler | sig_handler_ |
| TQ | timer_queue_ |
| ACE_Sig_Set | mask_ |
Mask of signals to be blocked when we're servicing SIGALRM. | |
This implementation uses the ACE_OS::ualarm call, to generate the SIGARLM signal that is caught by this class.
Definition at line 53 of file Timer_Queue_Adapters.h.
|
|||||
|
Definition at line 56 of file Timer_Queue_Adapters.h. |
|
||||||||||
|
Constructor.
Register the SIGALRM handler. If mask == 0 then block all signals when Definition at line 100 of file Timer_Queue_Adapters.cpp. References ACE_ERROR, ACE_SignalHandler, ACE_TEXT, LM_ERROR, ACE_Sig_Handler::register_handler(), SA_RESTART, and SIGALRM.
00103 : mask_ (mask) 00104 { 00105 // The following code is necessary to selectively "block" certain 00106 // signals when SIGALRM is running. Also, we always restart system 00107 // calls that are interrupted by the signals. 00108 00109 ACE_Sig_Action sa ((ACE_SignalHandler) 0, 00110 this->mask_, 00111 SA_RESTART); 00112 00113 if (this->sig_handler_.register_handler (SIGALRM, this, &sa) == -1) 00114 ACE_ERROR ((LM_ERROR, 00115 ACE_TEXT ("%p\n"), 00116 ACE_TEXT ("register_handler"))); 00117 } |
|
||||||||||||||||
|
Cancel the timer_id and pass back the act if an address is passed in. Definition at line 33 of file Timer_Queue_Adapters.cpp.
00035 {
00036 // Block designated signals.
00037 ACE_Sig_Guard sg (&this->mask_);
00038 ACE_UNUSED_ARG (sg);
00039
00040 return this->timer_queue_.cancel (timer_id, act);
00041 }
|
|
||||||||||
|
Dispatch all timers with expiry time at or before the current time. Returns the number of timers expired. Definition at line 44 of file Timer_Queue_Adapters.cpp.
00045 {
00046 // Block designated signals.
00047 ACE_Sig_Guard sg (&this->mask_);
00048 ACE_UNUSED_ARG (sg);
00049
00050 return this->timer_queue_.expire ();
00051 }
|
|
||||||||||||||||||||
|
Called back by
Reimplemented from ACE_Event_Handler. Definition at line 124 of file Timer_Queue_Adapters.cpp. References ACE_ERROR_RETURN, LM_ERROR, ACE_Async_Timer_Queue_Adapter< TQ >::schedule_ualarm(), SIGALRM, and ucontext_t.
00127 {
00128 switch (signum)
00129 {
00130 case SIGALRM:
00131 {
00132 // Expire the pending timers.
00133
00134 // @@ We need to figure out how to implement interval
00135 // timers...
00136 this->timer_queue_.expire ();
00137
00138 // Only schedule a new timer if there is one in the list.
00139
00140 // @@ This code should also become smarter to avoid
00141 // unnecessary calls to ualarm().
00142 if (this->timer_queue_.is_empty () == 0)
00143 return this->schedule_ualarm ();
00144 else
00145 return 0;
00146 /* NOTREACHED */
00147 }
00148 default:
00149 ACE_ERROR_RETURN ((LM_ERROR,
00150 "unexpected signal %S\n",
00151 signum),
00152 -1);
00153 /* NOTREACHED */
00154 }
00155 }
|
|
||||||||||||||||||||||||
|
This timer gets dispatched via a signal, rather than by a user calling expire(). Note that interval timers are not implemented yet. Definition at line 72 of file Timer_Queue_Adapters.cpp. References ACE_ERROR_RETURN, ACE_TEXT, LM_ERROR, and ACE_Async_Timer_Queue_Adapter< TQ >::schedule_ualarm().
00076 {
00077 ACE_UNUSED_ARG (act);
00078 ACE_UNUSED_ARG (interval);
00079
00080 // Block designated signals.
00081 ACE_Sig_Guard sg (&this->mask_);
00082 ACE_UNUSED_ARG (sg);
00083
00084 // @@ We still need to implement interval timers...
00085 long tid = this->timer_queue_.schedule (eh, act, future_time);
00086
00087 if (tid == -1)
00088 ACE_ERROR_RETURN ((LM_ERROR,
00089 ACE_TEXT ("%p\n"),
00090 ACE_TEXT ("schedule_timer")),
00091 -1);
00092
00093 if (this->schedule_ualarm () == -1)
00094 return 0;
00095
00096 return tid;
00097 }
|
|
||||||||||
|
Perform the logic to compute the new ualarm(2) setting.
Definition at line 54 of file Timer_Queue_Adapters.cpp. References ACE_Time_Value, and ACE_OS::ualarm(). Referenced by ACE_Async_Timer_Queue_Adapter< TQ >::handle_signal(), and ACE_Async_Timer_Queue_Adapter< TQ >::schedule().
00055 {
00056 ACE_Time_Value tv = this->timer_queue_.earliest_time ()
00057 - this->timer_queue_.gettimeofday ();
00058
00059 // Beware of negative times and zero times (which cause problems for
00060 // <ualarm>).
00061 if (tv < ACE_Time_Value::zero)
00062 tv = ACE_Time_Value (0, 1);
00063
00064 // @@ This code should be clever enough to avoid updating the
00065 // <ualarm> if we haven't actually changed the earliest time.
00066 // Schedule a new timer.
00067 ACE_OS::ualarm (tv);
00068 return 0;
00069 }
|
|
||||||||||
|
Return a reference to the underlying timer queue.
Definition at line 27 of file Timer_Queue_Adapters.cpp.
00028 {
00029 return this->timer_queue_;
00030 }
|
|
|||||
|
Mask of signals to be blocked when we're servicing
Definition at line 105 of file Timer_Queue_Adapters.h. |
|
|||||
|
Handler for the Definition at line 98 of file Timer_Queue_Adapters.h. |
|
|||||
|
Implementation of the timer queue (e.g., ACE_Timer_List, ACE_Timer_Heap, etc.). Definition at line 102 of file Timer_Queue_Adapters.h. |
1.3.6