Compile fixes
[ACE_TAO.git] / ACE / tests / Proactor_Test.h
blobe6c2f6f0706e32db3bd02436503c613e6a04eb3e
2 //=============================================================================
3 /**
4 * @file Proactor_Test.h
6 * Define class needed for generating templates. IBM C++ requires this to
7 * be in its own file for auto template instantiation.
9 * @author @author Alexander Libman <alibman@baltimore.com>
11 //=============================================================================
14 #ifndef ACE_TESTS_PROACTOR_TEST_H
15 #define ACE_TESTS_PROACTOR_TEST_H
17 #include "ace/Synch_Traits.h"
18 #include "ace/Thread_Mutex.h"
20 // forward declaration
21 class TestData;
23 class Server : public ACE_Service_Handler
25 public:
26 Server ();
27 Server (TestData *tester, int id);
28 ~Server ();
30 int id () { return this->id_; }
31 size_t get_total_snd () { return this->total_snd_; }
32 size_t get_total_rcv () { return this->total_rcv_; }
33 long get_total_w () { return this->total_w_; }
34 long get_total_r () { return this->total_r_; }
36 // This is called to pass the new connection's addresses.
37 virtual void addresses (const ACE_INET_Addr& peer,
38 const ACE_INET_Addr& local);
40 /// This is called after the new connection has been accepted.
41 virtual void open (ACE_HANDLE handle,
42 ACE_Message_Block &message_block);
43 void cancel ();
45 protected:
46 //// This is called when asynchronous <read> operation from the
47 //// socket completes.
48 /**
49 * @name AIO callback handling
51 * These methods are called by the framework
53 virtual void handle_read_stream (const ACE_Asynch_Read_Stream::Result &result);
55 /// This is called when an asynchronous <write> to the socket
56 /// completes.
57 virtual void handle_write_stream (const ACE_Asynch_Write_Stream::Result &result);
59 private:
60 int initiate_read_stream ();
61 int initiate_write_stream (ACE_Message_Block &mb, size_t nbytes);
63 TestData *tester_;
64 int id_;
66 ACE_Asynch_Read_Stream rs_;
67 ACE_Asynch_Write_Stream ws_;
68 ACE_HANDLE handle_;
69 ACE_SYNCH_MUTEX lock_;
71 int io_count_; // Number of currently outstanding I/O requests
72 int flg_cancel_;
73 size_t total_snd_; // Number of bytes successfully sent
74 size_t total_rcv_; // Number of bytes successfully received
75 int total_w_; // Number of write operations
76 int total_r_; // Number of read operations
79 // *******************************************
80 // Client
81 // *******************************************
83 class Client : public ACE_Service_Handler
85 public:
86 /// This is called after the new connection has been established.
87 virtual void open (ACE_HANDLE handle,
88 ACE_Message_Block &message_block);
90 Client ();
91 Client (TestData *tester, int id);
92 ~Client ();
94 int id () { return this->id_; }
95 size_t get_total_snd () { return this->total_snd_; }
96 size_t get_total_rcv () { return this->total_rcv_; }
97 int get_total_w () { return this->total_w_; }
98 int get_total_r () { return this->total_r_; }
100 // This is called to pass the new connection's addresses.
101 virtual void addresses (const ACE_INET_Addr& peer,
102 const ACE_INET_Addr& local);
104 /// This is called when asynchronous reads from the socket complete
105 virtual void handle_read_stream (const ACE_Asynch_Read_Stream::Result &result);
107 /// This is called when asynchronous writes from the socket complete
108 virtual void handle_write_stream (const ACE_Asynch_Write_Stream::Result &result);
110 void cancel ();
112 private:
113 int initiate_read_stream ();
114 int initiate_write_stream ();
115 void close ();
117 TestData *tester_;
118 int id_;
120 ACE_Asynch_Read_Stream rs_;
121 ACE_Asynch_Write_Stream ws_;
122 ACE_HANDLE handle_;
124 ACE_SYNCH_MUTEX lock_;
126 int io_count_;
127 int stop_writing_; // Writes are shut down; just read.
128 int flg_cancel_;
129 size_t total_snd_;
130 size_t total_rcv_;
131 int total_w_;
132 int total_r_;
135 #endif /* ACE_TESTS_PROACTOR_TEST_H */