Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / examples / Timer_Queue / Async_Timer_Queue_Test.h
blob69d4568118fc297e6b0a8792e7034bbc926e62b1
1 /* -*- C++ -*- */
4 //=============================================================================
5 /**
6 * @file Async_Timer_Queue_Test.h
8 * This test exercises the <ACE_Asynch_Timer_Queue_Adapter>
9 * using an <ACE_Timer_Heap>.
11 * @author Douglas C. Schmidt and Sergio Flores-Gaitan
13 //=============================================================================
16 #ifndef _ASYNC_TIMER_QUEUE_TEST_H_
17 #define _ASYNC_TIMER_QUEUE_TEST_H_
19 #include "ace/Signal.h"
20 #include "ace/svc_export.h"
22 #if !defined (ACE_LACKS_PRAGMA_ONCE)
23 # pragma once
24 #endif /* ACE_LACKS_PRAGMA_ONCE */
26 #include "ace/Timer_Heap.h"
27 #include "ace/Timer_Queue_Adapters.h"
29 #include "Driver.h"
31 /**
32 * @class Async_Timer_Handler
34 * @brief Target of the asynchronous timeout operation.
36 class Async_Timer_Handler : public ACE_Event_Handler
38 public:
39 /// Callback hook invoked by the <Timer_Queue>.
40 virtual int handle_timeout (const ACE_Time_Value &tv,
41 const void *arg);
44 /**
45 * @class Async_Timer_Queue
47 * @brief Asynchronous Timer Queue Singleton.
49 * We use this class to avoid global variables and to
50 * consolidate all the Timer Queue processing in one central
51 * place.
53 class Async_Timer_Queue
55 public:
56 typedef int (Async_Timer_Queue::*ACTION) (void *);
58 /// Singleton access point.
59 static Async_Timer_Queue *instance ();
61 /// Schedule a timer to expire <microsecs> in the future.
62 void schedule (u_int microsecs);
64 /// Cancel a timer with <timer_id>.
65 void cancel (long timer_id);
67 /// Dump the contents of the queue.
68 void dump ();
70 /// hook method to schedule a timer. Called from
71 /// <Timer_Queue_Test_Driver>
72 int schedule_timer (void *argument);
74 /// hook method to cancel a timer. Called from
75 /// <Timer_Queue_Test_Driver>
76 int cancel_timer (void *argument);
78 /// hook method to list timers. Called from
79 /// <Timer_Queue_Test_Driver>
80 int list_timer (void *argument);
82 /// hook method to exit the timer queue. Called from
83 /// <Timer_Queue_Test_Driver>
84 int shutdown_timer (void *argument);
86 private:
87 /// Private constructor enforces the Singleton.
88 Async_Timer_Queue (ACE_Sig_Set *);
90 /// Pointer to the timer queue.
91 static Async_Timer_Queue *instance_;
93 /// The adapter is instantiated by an <ACE_Timer_Heap>.
94 ACE_Async_Timer_Queue_Adapter<ACE_Timer_Heap> tq_;
97 /**
98 * @class Async_Timer_Queue_Test_Driver
100 * @brief Async_Timer_Queue_Test_Driver
102 * This class implements a test driver for the
103 * <Async_Timer_Queue>. Implements a display_menu() method that
104 * prints the options for a user. and init() which initializes
105 * the driver. The rest of the common functionality is in the
106 * parent class <Timer_Queue_Test_Driver>.
108 class ACE_Svc_Export Async_Timer_Queue_Test_Driver : public Timer_Queue_Test_Driver <Async_Timer_Queue *, Async_Timer_Queue, Async_Timer_Queue::ACTION>
110 public:
111 Async_Timer_Queue_Test_Driver ();
113 /// Print menu of options.
114 virtual int display_menu ();
116 /// Initializes the driver's internal variables inherited from the parent
117 virtual int init ();
120 #endif /* _ASYNC_TIMER_QUEUE_TEST_H_ */