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
>
40 int verify_results(void);
42 /// Run by a daemon thread to handle deferred processing.
43 virtual int svc (void);
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 */
73 * @class Dispatch_Count_Handler
75 * @brief A simple test to ensure that the Reactor counts the number of
76 * dispatches correctly.
78 class Dispatch_Count_Handler
: public ACE_Event_Handler
81 Dispatch_Count_Handler (void);
83 /// Clean up resources from the Reactor.
84 int handle_close (ACE_HANDLE h
,
87 /// Keep track of the number of timeouts.
88 virtual int handle_timeout (const ACE_Time_Value
&tv
,
91 /// Keep track of the number of I/O events.
92 virtual int handle_input (ACE_HANDLE
);
94 /// Keep track of the number of notifies.
95 virtual int handle_exception (ACE_HANDLE
);
97 /// Verify that the expected events did happen.
98 int verify_results (void);
101 /// Provide something to trigger I/O.
106 size_t timers_fired_
;
110 #endif /* ACE_TESTS_MT_REACTOR_TIMER_TEST_H */