Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / examples / Timer_Queue / Custom_Handler.cpp
blob5e7357260e9056dbf1e82389f1702345d5e5b415
1 //=============================================================================
2 /**
3 * @file Custom_Handler.cpp
5 * This is a custom event handler to be used with the thread timer queue
6 * adapter, and its appropriate upcall.
8 * @author Alon Diamant <diamant.alon@gmail.com
9 */
10 //=============================================================================
13 #include "Custom_Handler.h"
14 #include "ace/OS_NS_stdio.h"
16 Custom_Handler::Custom_Handler(const ACE_Time_Value &expiration_time)
17 : expires_ (expiration_time),
18 id_ (0)
22 Custom_Handler::~Custom_Handler ()
26 void
27 Custom_Handler::set_id (int id)
29 this->id_ = id;
32 // This is the method invoked when the Timer expires.
33 int
34 Custom_Handler::on_timeout (const ACE_Time_Value &current_time,
35 const void *)
37 ACE_Time_Value delay = current_time - this->expires_;
39 // No need to protect this printf is always called from a Async safe
40 // point.
41 ACE_OS::printf ("\nexpiring timer %d at %lu.%7.7lu secs\n"
42 "\tthere was a %lu.%7.7lu secs delay\n",
43 this->id_,
44 static_cast<unsigned long> (current_time.sec ()),
45 static_cast<unsigned long> (current_time.usec ()),
46 static_cast<unsigned long> (delay.sec ()),
47 static_cast<unsigned long> (delay.usec ()));
49 // Notice this delete is protected.
50 delete this;
52 return 0;
55 int Custom_Handler_Upcall::registration(TTimerQueue& , Custom_Handler* , const void* )
57 ACE_TRACE("registration");
59 return 0;
62 int Custom_Handler_Upcall::preinvoke(TTimerQueue& , Custom_Handler* , const void* , int , const ACE_Time_Value& , const void*& )
64 ACE_TRACE("preinvoke");
66 return 0;
69 int Custom_Handler_Upcall::timeout(TTimerQueue& , Custom_Handler* handler, const void* arg, int , const ACE_Time_Value& cur_time)
71 ACE_TRACE("timeout");
73 // Do the actual timer call
74 handler->on_timeout(cur_time, arg);
76 return 0;
79 int Custom_Handler_Upcall::postinvoke(TTimerQueue& , Custom_Handler* , const void* , int , const ACE_Time_Value& , const void* )
81 ACE_TRACE("postinvoke");
83 return 0;
86 int Custom_Handler_Upcall::cancel_type(TTimerQueue& , Custom_Handler* , int , int& )
88 ACE_TRACE("cancel_type");
90 return 0;
93 int Custom_Handler_Upcall::cancel_timer(TTimerQueue& , Custom_Handler* handler, int , int )
95 ACE_TRACE("cancel_timer");
96 delete handler;
97 return 0;
100 int Custom_Handler_Upcall::deletion(TTimerQueue& , Custom_Handler* handler, const void* )
102 ACE_TRACE("deletion");
103 delete handler;
104 return 0;