Revert "Use a variable on the stack to not have a temporary in the call"
[ACE_TAO.git] / ACE / tests / MT_Reactor_Timer_Test.h
blob7302db9a3b242987d5dbf77d5d79b46f7a9da52a
1 /* -*- C++ -*- */
3 //=============================================================================
4 /**
5 * @file MT_Reactor_Timer_Test.h
7 * This file contains class definitions needed for template
8 * instantiation in the MT_Reactor_Timer_Test.cpp file.
10 * @author Steve Huston <shuston@riverace.com>
12 //=============================================================================
15 #ifndef ACE_TESTS_MT_REACTOR_TIMER_TEST_H
16 #define ACE_TESTS_MT_REACTOR_TIMER_TEST_H
18 #include "ace/Reactor.h"
20 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 # pragma once
22 #endif /* ACE_LACKS_PRAGMA_ONCE */
24 #include "ace/Task.h"
25 #include "ace/Pipe.h"
27 /**
28 * @class Time_Handler
30 * @brief Test out the multi-threading features of the Reactor's timer
31 * mechanism.
33 class Time_Handler : public ACE_Task<ACE_SYNCH>
35 public:
36 Time_Handler ();
38 void setup ();
40 int verify_results();
42 /// Run by a daemon thread to handle deferred processing.
43 virtual int svc ();
45 virtual int handle_timeout (const ACE_Time_Value &tv,
46 const void *arg);
48 private:
49 enum
51 TIMER_SLOTS = 10
54 /**
55 * The timer_id_ array holds timer IDs. They also have some other values
56 * that are specific to this test:
57 * -1 the timer has not been set
58 * -2 the timer was set, but has been cancelled
59 * -3 the timer was set, and it already fired
61 long timer_id_[TIMER_SLOTS];
62 enum { TIMER_NOTSET = -1, TIMER_CANCELLED = -2, TIMER_FIRED = -3 };
64 long prev_timer_;
66 #if defined ACE_HAS_THREADS
67 ACE_Thread_Mutex lock_;
68 #endif /* ACE_HAS_THREADS */
71 /**
72 * @class Dispatch_Count_Handler
74 * @brief A simple test to ensure that the Reactor counts the number of
75 * dispatches correctly.
77 class Dispatch_Count_Handler : public ACE_Event_Handler
79 public:
80 Dispatch_Count_Handler ();
82 /// Clean up resources from the Reactor.
83 int handle_close (ACE_HANDLE h,
84 ACE_Reactor_Mask m);
86 /// Keep track of the number of timeouts.
87 virtual int handle_timeout (const ACE_Time_Value &tv,
88 const void *arg);
90 /// Keep track of the number of I/O events.
91 virtual int handle_input (ACE_HANDLE);
93 /// Keep track of the number of notifies.
94 virtual int handle_exception (ACE_HANDLE);
96 /// Verify that the expected events did happen.
97 int verify_results ();
99 private:
100 /// Provide something to trigger I/O.
101 ACE_Pipe pipe_;
103 int input_seen_;
104 int notify_seen_;
105 size_t timers_fired_;
108 #endif /* ACE_TESTS_MT_REACTOR_TIMER_TEST_H */