Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / examples / Timer_Queue / Thread_Timer_Queue_Custom_Handler_Test.h
blob452543671f996f6fbd6511127d026a709f4a7000
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file Thread_Timer_Queue_Custom_Handler_Test.h
7 * This code exercises the <ACE_Thread_Timer_Queue_Adapter> using
8 * an <ACE_Timer_Heap_T>. It also demonstrates using a custom handler for
9 * timer events.
11 * @author Carlos O'Ryan <coryan@cs.wustl.edu> and Sergio Flores-Gaitan <sergio@cs.wustl.edu> and Alon Diamant <diamant.alon@gmail.com>
13 //=============================================================================
16 #ifndef _THREAD_TIMER_QUEUE_TEST_H_
17 #define _THREAD_TIMER_QUEUE_TEST_H_
19 #include "ace/Task.h"
21 #if !defined (ACE_LACKS_PRAGMA_ONCE)
22 # pragma once
23 #endif /* ACE_LACKS_PRAGMA_ONCE */
25 #include "ace/Null_Mutex.h"
26 #include "ace/Timer_Heap_T.h"
27 #include "ace/Timer_Queue_Adapters.h"
28 #include "ace/svc_export.h"
29 #include "ace/Condition_Recursive_Thread_Mutex.h"
30 #include "Driver.h"
31 #include "Custom_Handler.h"
33 // These typedefs ensure that we use the minimal amount of locking
34 // necessary.
35 typedef ACE_Timer_Heap_T<Custom_Handler*,
36 Custom_Handler_Upcall,
37 ACE_Null_Mutex>
38 Timer_Heap;
39 typedef ACE_Timer_Heap_Iterator_T<Custom_Handler*,
40 Custom_Handler_Upcall,
41 ACE_Null_Mutex>
42 Timer_Heap_Iterator;
43 typedef ACE_Thread_Timer_Queue_Adapter<Timer_Heap, Custom_Handler*>
44 Thread_Timer_Queue;
46 // Forward declaration.
47 class Thread_Timer_Queue_Custom_Handler_Test;
49 /**
50 * @class Custom_Handler_Input_Task
52 * @brief Read user actions on the Timer_Queue from stdin.
54 * This class reads user input from stdin; those commands permit
55 * the control of a Timer_Queue, which is dispatched by another
56 * thread.
58 class Custom_Handler_Input_Task : public ACE_Task_Base
60 public:
61 typedef int (Custom_Handler_Input_Task::*ACTION) (void *);
63 Custom_Handler_Input_Task (Thread_Timer_Queue *queue,
64 Thread_Timer_Queue_Custom_Handler_Test &timer_queue_driver);
66 /// This method runs the event loop in the new thread.
67 virtual int svc ();
69 // = Some helper methods.
71 /// Add a new timer to expire in <seconds> more.
72 int add_timer (void *);
74 /// Cancel timer <id>.
75 int cancel_timer (void *);
77 /// List the current scheduled timers.
78 int list_timer (void *);
80 /// Shutdown task.
81 int shutdown_timer (void *);
83 /// Dump the state of the timer queue.
84 void dump ();
86 private:
87 /// The timer queue implementation.
88 Thread_Timer_Queue *queue_;
90 /// How many micro seconds are in a second.
91 const int usecs_;
93 /// The thread timer queue test driver.
94 Thread_Timer_Queue_Custom_Handler_Test &driver_;
97 /**
98 * @class Thread_Timer_Queue_Custom_Handler_Test
100 * @brief Implements an example application that exercises
101 * <Thread_Timer_Queue> timer queue.
103 * This class implements a simple test driver for the
104 * <Thread_Timer_Queue>. The <display_menu> hook method is
105 * called from the base class to print a menu specific to the
106 * thread implementation of the timer queue.
108 class ACE_Svc_Export Thread_Timer_Queue_Custom_Handler_Test : public Timer_Queue_Test_Driver <Thread_Timer_Queue, Custom_Handler_Input_Task, Custom_Handler_Input_Task::ACTION>
110 public:
111 Thread_Timer_Queue_Custom_Handler_Test ();
112 ~Thread_Timer_Queue_Custom_Handler_Test ();
114 virtual int display_menu ();
115 virtual int init ();
116 virtual int run_test ();
118 private:
119 /// Subclassed from ACE_Task.
120 Custom_Handler_Input_Task input_task_;
123 #endif /* _THREAD_TIMER_QUEUE_TEST_H_ */