Merge pull request #2301 from sonndinh/remove-dup-reactor-functions
[ACE_TAO.git] / ACE / tests / Priority_Reactor_Test.h
blob44b64f7bbd16727afeb71e3e90864e84e210fe05
2 //=============================================================================
3 /**
4 * @file Priority_Reactor_Test.h
6 * It is only used by Priority_Reactor_Test.cpp.
8 * @author Carlos O'Ryan <coryan@cs.wustl.edu>
9 */
10 //=============================================================================
13 #ifndef ACE_TESTS_PRIORITY_REACTOR_TEST_H
14 #define ACE_TESTS_PRIORITY_REACTOR_TEST_H
16 #include "ace/Service_Config.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 # pragma once
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #include "ace/SOCK_Stream.h"
23 #include "ace/Svc_Handler.h"
25 /**
26 * @class Read_Handler
28 * @brief A Svc_Handler with a priority twist.
30 * This Svc_Handler receives the data sent by the childs or writer
31 * threads; each one sets it own priority to a new level, in a
32 * cyclic manner. The main point is test and exercise the
33 * priority dispatching features of ACE_Priority_Reactor.
35 class Read_Handler : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_SYNCH>
37 public:
38 /// Set the number of children or writer threads we will be running,
39 /// when they are all gone we terminate the reactor loop.
40 static void set_countdown (int nchildren);
42 /// Get the number of children we are still waiting for.
43 static int get_countdown ();
45 /// The Svc_Handler callbacks.
46 virtual int open (void *);
47 virtual int handle_input (ACE_HANDLE h);
49 private:
50 /// How many writers are we waiting for.
51 static int waiting_;
53 /// How many readers have started.
54 static int started_;
57 /**
58 * @class Write_Handler
60 * @brief A simple writer.
62 * This Svc_Handler simply connects to a server and sends some
63 * output to it. Its purpose is to feed the test.
65 class Write_Handler : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_SYNCH>
67 public:
68 virtual int open (void *);
69 virtual int svc ();
72 #endif /* ACE_TESTS_PRIORITY_REACTOR_TEST_H */