1 #include "ace/OS_NS_sys_time.h"
4 #include "ace/Timer_Queue_Adapters.h"
5 #include "ace/Timer_Heap.h"
7 typedef ACE_Thread_Timer_Queue_Adapter
<ACE_Timer_Heap
>
11 // Listing 2 code/ch20
12 class CB
: public ACE_Event_Handler
15 CB (int id
) : id_(id
) { }
17 virtual int handle_timeout (const ACE_Time_Value
&,
20 ACE_TRACE ("CB::handle_timeout");
22 const int *val
= static_cast<const int*> (arg
);
23 ACE_ASSERT((*val
) == id_
);
28 ACE_TEXT ("Expiry handled by thread %t\n")));
37 // Listing 3 code/ch20
38 int ACE_TMAIN (int, ACE_TCHAR
*[])
41 ACE_TEXT ("the main thread %t has started\n")));
43 // Create an "active" timer and start its thread.
52 // Schedule timers to go off 3 & 4 seconds from now
53 // and then with an interval of 1.1 seconds.
54 const ACE_Time_Value curr_tv
= ACE_OS::gettimeofday ();
55 ACE_Time_Value interval
= ACE_Time_Value (1, 100000);
57 atimer
.schedule (&cb1
,
59 curr_tv
+ ACE_Time_Value (3L),
61 atimer
.schedule (&cb2
,
63 curr_tv
+ ACE_Time_Value (4L),
66 ACE_Thread_Manager::instance ()->wait (); // Wait forever.