Make x.0.10 publicly available
[ACE_TAO.git] / ACE / tests / Priority_Reactor_Test.h
blob7bdc5ff9d1dea23da3c8db339208358187e5fefa
2 //=============================================================================
3 /**
4 * @file Priority_Reactor_Test.h
6 * This class gets its own header file to work around AIX C++
7 * compiler "features" related to template instantiation... It is
8 * only used by Priority_Reactor_Test.cpp.
10 * @author Carlos O'Ryan <coryan@cs.wustl.edu>
12 //=============================================================================
15 #ifndef ACE_TESTS_PRIORITY_REACTOR_TEST_H
16 #define ACE_TESTS_PRIORITY_REACTOR_TEST_H
18 #include "ace/Service_Config.h"
20 #if !defined (ACE_LACKS_PRAGMA_ONCE)
21 # pragma once
22 #endif /* ACE_LACKS_PRAGMA_ONCE */
24 #include "ace/SOCK_Stream.h"
25 #include "ace/Svc_Handler.h"
27 /**
28 * @class Read_Handler
30 * @brief A Svc_Handler with a priority twist.
32 * This Svc_Handler receives the data sent by the childs or writer
33 * threads; each one sets it own priority to a new level, in a
34 * cyclic manner. The main point is test and exercise the
35 * priority dispatching features of ACE_Priority_Reactor.
37 class Read_Handler : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_SYNCH>
39 public:
40 /// Set the number of children or writer threads we will be running,
41 /// when they are all gone we terminate the reactor loop.
42 static void set_countdown (int nchildren);
44 /// Get the number of children we are still waiting for.
45 static int get_countdown ();
47 /// The Svc_Handler callbacks.
48 virtual int open (void *);
49 virtual int handle_input (ACE_HANDLE h);
51 private:
52 /// How many writers are we waiting for.
53 static int waiting_;
55 /// How many readers have started.
56 static int started_;
59 /**
60 * @class Write_Handler
62 * @brief A simple writer.
64 * This Svc_Handler simply connects to a server and sends some
65 * output to it. Its purpose is to feed the test.
67 class Write_Handler : public ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_SYNCH>
69 public:
70 virtual int open (void *);
71 virtual int svc ();
74 #endif /* ACE_TESTS_PRIORITY_REACTOR_TEST_H */