3 //=============================================================================
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)
22 #endif /* ACE_LACKS_PRAGMA_ONCE */
30 * @brief Test out the multi-threading features of the Reactor's timer
33 class Time_Handler
: public ACE_Task
<ACE_SYNCH
>
42 /// Run by a daemon thread to handle deferred processing.
45 virtual int handle_timeout (const ACE_Time_Value
&tv
,
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 };
66 #if defined ACE_HAS_THREADS
67 ACE_Thread_Mutex lock_
;
68 #endif /* ACE_HAS_THREADS */
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
80 Dispatch_Count_Handler ();
82 /// Clean up resources from the Reactor.
83 int handle_close (ACE_HANDLE h
,
86 /// Keep track of the number of timeouts.
87 virtual int handle_timeout (const ACE_Time_Value
&tv
,
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 ();
100 /// Provide something to trigger I/O.
105 size_t timers_fired_
;
108 #endif /* ACE_TESTS_MT_REACTOR_TIMER_TEST_H */