Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / examples / Timer_Queue / Custom_Handler.h
blob3da0b1aab3274d562abc3b706089af57a533aec4
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file Custom_Handler.h
7 * This is a custom event handler to be used with the thread timer queue
8 * adapter, and its appropriate upcall.
10 * @author Alon Diamant <diamant.alon@gmail.com>
12 //=============================================================================
15 #ifndef _CUSTOM_HANDLER_H_
16 #define _CUSTOM_HANDLER_H_
18 #include "ace/Timer_Queue.h"
19 #include "ace/svc_export.h"
21 /**
22 * @class Custom_Handler
24 * @brief Custom event handler for the timer queue timeout events.
26 * The <on_timeout> hook method prints out the current time,
27 * prints the time when this timer expired and deletes "this".
29 class Custom_Handler
31 public:
32 Custom_Handler (const ACE_Time_Value &expiration_time);
34 virtual ~Custom_Handler ();
36 // Set the custom handler's id
37 void set_id (int id);
39 // Call back hook.
40 virtual int on_timeout(const ACE_Time_Value &current_time,
41 const void *arg);
43 private:
44 // Store the expected time of expiration, it is used to print a nice
45 // message saying how much delay was at the actual expiration time.
46 ACE_Time_Value expires_;
48 // Store an "id" for the Handler, which is only use to print better
49 // messages.
50 int id_;
54 /// CWorkItemAndParamTupleUpcall
55 ///
56 /// Implements the Upcall interface used by the ACE_Timer_Queue, specifically for the
57 /// IWorkItem interface.
58 class ACE_Svc_Export Custom_Handler_Upcall
60 public:
61 typedef ACE_Timer_Queue_T<Custom_Handler*,
62 Custom_Handler_Upcall,
63 ACE_Null_Mutex> TTimerQueue;
65 // Default constructor
66 Custom_Handler_Upcall()
70 // Destructor.
71 ~Custom_Handler_Upcall()
75 // This method is called when a timer is registered.
76 int registration(TTimerQueue& timer_queue,
77 Custom_Handler* handler,
78 const void* arg);
80 // This method is called before the timer expires.
81 int preinvoke(TTimerQueue& timer_queue,
82 Custom_Handler* handler,
83 const void* arg,
84 int recurring_timer,
85 const ACE_Time_Value& cur_time,
86 const void*& upcall_act);
88 // This method is called when the timer expires.
89 int timeout (TTimerQueue& timer_queue,
90 Custom_Handler* handler,
91 const void* arg,
92 int recurring_timer,
93 const ACE_Time_Value& cur_time);
95 // This method is called after the timer expires.
96 int postinvoke(TTimerQueue& timer_queue,
97 Custom_Handler* handler,
98 const void* arg,
99 int recurring_timer,
100 const ACE_Time_Value& cur_time,
101 const void* upcall_act);
103 // This method is called when a handler is canceled
104 int cancel_type(TTimerQueue& timer_queue,
105 Custom_Handler* handler,
106 int dont_call,
107 int& requires_reference_counting);
109 // This method is called when a timer is canceled
110 int cancel_timer(TTimerQueue& timer_queue,
111 Custom_Handler* handler,
112 int dont_call,
113 int requires_reference_counting);
115 // This method is called when the timer queue is destroyed and
116 // the timer is still contained in it
117 int deletion(TTimerQueue& timer_queue,
118 Custom_Handler* handler,
119 const void* arg);
122 #endif