#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 50 of file Timer_Queue_Adapters.h.
|
|||||
|
Definition at line 53 of file Timer_Queue_Adapters.h. |
|
||||||||||
|
Constructor.
Register the SIGALRM handler. If mask == 0 then block all signals when Definition at line 95 of file Timer_Queue_Adapters.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_SignalHandler, LM_ERROR, ACE_Sig_Handler::register_handler(), SA_RESTART, and SIGALRM.
00098 : mask_ (mask) 00099 { 00100 // The following code is necessary to selectively "block" certain 00101 // signals when SIGALRM is running. Also, we always restart system 00102 // calls that are interrupted by the signals. 00103 00104 ACE_Sig_Action sa ((ACE_SignalHandler) 0, 00105 this->mask_, 00106 SA_RESTART); 00107 00108 if (this->sig_handler_.register_handler (SIGALRM, this, &sa) == -1) 00109 ACE_ERROR ((LM_ERROR, 00110 ACE_LIB_TEXT ("%p\n"), 00111 ACE_LIB_TEXT ("register_handler"))); 00112 } |
|
||||||||||||||||
|
Cancel the timer_id and pass back the act if an address is passed in. Definition at line 28 of file Timer_Queue_Adapters.cpp.
00030 {
00031 // Block designated signals.
00032 ACE_Sig_Guard sg (&this->mask_);
00033 ACE_UNUSED_ARG (sg);
00034
00035 return this->timer_queue_.cancel (timer_id, act);
00036 }
|
|
||||||||||
|
Dispatch all timers with expiry time at or before the current time. Returns the number of timers expired. Definition at line 39 of file Timer_Queue_Adapters.cpp.
00040 {
00041 // Block designated signals.
00042 ACE_Sig_Guard sg (&this->mask_);
00043 ACE_UNUSED_ARG (sg);
00044
00045 return this->timer_queue_.expire ();
00046 }
|
|
||||||||||||||||||||
|
Called back by
Reimplemented from ACE_Event_Handler. Definition at line 119 of file Timer_Queue_Adapters.cpp. References ACE_ERROR_RETURN, LM_ERROR, ACE_Async_Timer_Queue_Adapter< TQ >::schedule_ualarm(), SIGALRM, and ucontext_t.
00122 {
00123 switch (signum)
00124 {
00125 case SIGALRM:
00126 {
00127 // Expire the pending timers.
00128
00129 // @@ We need to figure out how to implement interval
00130 // timers...
00131 this->timer_queue_.expire ();
00132
00133 // Only schedule a new timer if there is one in the list.
00134
00135 // @@ This code should also become smarter to avoid
00136 // unnecessary calls to ualarm().
00137 if (this->timer_queue_.is_empty () == 0)
00138 return this->schedule_ualarm ();
00139 else
00140 return 0;
00141 /* NOTREACHED */
00142 }
00143 default:
00144 ACE_ERROR_RETURN ((LM_ERROR,
00145 "unexpected signal %S\n",
00146 signum),
00147 -1);
00148 /* NOTREACHED */
00149 }
00150 }
|
|
||||||||||||||||||||||||
|
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 67 of file Timer_Queue_Adapters.cpp. References ACE_ERROR_RETURN, ACE_LIB_TEXT, LM_ERROR, and ACE_Async_Timer_Queue_Adapter< TQ >::schedule_ualarm().
00071 {
00072 ACE_UNUSED_ARG (act);
00073 ACE_UNUSED_ARG (interval);
00074
00075 // Block designated signals.
00076 ACE_Sig_Guard sg (&this->mask_);
00077 ACE_UNUSED_ARG (sg);
00078
00079 // @@ We still need to implement interval timers...
00080 long tid = this->timer_queue_.schedule (eh, act, future_time);
00081
00082 if (tid == -1)
00083 ACE_ERROR_RETURN ((LM_ERROR,
00084 ACE_LIB_TEXT ("%p\n"),
00085 ACE_LIB_TEXT ("schedule_timer")),
00086 -1);
00087
00088 if (this->schedule_ualarm () == -1)
00089 return 0;
00090
00091 return tid;
00092 }
|
|
||||||||||
|
Perform the logic to compute the new ualarm(2) setting.
Definition at line 49 of file Timer_Queue_Adapters.cpp. References ACE_Time_Value, ACE_OS::gettimeofday(), and ACE_OS::ualarm(). Referenced by ACE_Async_Timer_Queue_Adapter< TQ >::handle_signal(), and ACE_Async_Timer_Queue_Adapter< TQ >::schedule().
00050 {
00051 ACE_Time_Value tv = this->timer_queue_.earliest_time ()
00052 - ACE_OS::gettimeofday ();
00053
00054 // Beware of negative times and zero times (which cause problems for
00055 // <ualarm>).
00056 if (tv < ACE_Time_Value::zero)
00057 tv = ACE_Time_Value (0, 1);
00058
00059 // @@ This code should be clever enough to avoid updating the
00060 // <ualarm> if we haven't actually changed the earliest time.
00061 // Schedule a new timer.
00062 ACE_OS::ualarm (tv);
00063 return 0;
00064 }
|
|
||||||||||
|
Return a reference to the underlying timer queue.
Definition at line 22 of file Timer_Queue_Adapters.cpp.
00023 {
00024 return this->timer_queue_;
00025 }
|
|
|||||
|
Mask of signals to be blocked when we're servicing
Definition at line 102 of file Timer_Queue_Adapters.h. |
|
|||||
|
Handler for the Definition at line 95 of file Timer_Queue_Adapters.h. |
|
|||||
|
Implementation of the timer queue (e.g., ACE_Timer_List, ACE_Timer_Heap, etc.). Definition at line 99 of file Timer_Queue_Adapters.h. |
1.3.6