summaryrefslogtreecommitdiff
path: root/tests/Proactor_Test.h
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2004-03-15 21:12:55 +0000
committerSteve Huston <shuston@riverace.com>2004-03-15 21:12:55 +0000
commitc2ae73d1963409a496c2dbefb0ee1505b944c2c8 (patch)
tree7a5426a7c07429b799aad934292f5dece9b23033 /tests/Proactor_Test.h
parent358e872a4d031b10f56c440e191a7be22ce0cd0f (diff)
downloadATCD-c2ae73d1963409a496c2dbefb0ee1505b944c2c8.tar.gz
ChangeLogTag:Mon Mar 15 15:42:33 2004 Steve Huston <shuston@riverace.com>
Diffstat (limited to 'tests/Proactor_Test.h')
-rw-r--r--tests/Proactor_Test.h141
1 files changed, 141 insertions, 0 deletions
diff --git a/tests/Proactor_Test.h b/tests/Proactor_Test.h
new file mode 100644
index 00000000000..6d36e5fe137
--- /dev/null
+++ b/tests/Proactor_Test.h
@@ -0,0 +1,141 @@
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// tests
+//
+// = FILENAME
+// Proactor_Test.h
+//
+// = DESCRIPTION
+// Define class needed for generating templates. IBM C++ requires this to
+// be in its own file for auto template instantiation.
+//
+// = AUTHOR
+// @author Alexander Libman <alibman@baltimore.com>
+//
+// ============================================================================
+
+#ifndef ACE_TESTS_PROACTOR_TEST_H
+#define ACE_TESTS_PROACTOR_TEST_H
+
+#include "ace/Synch_Traits.h"
+#include "ace/Thread_Mutex.h"
+
+// forward declaration
+class Acceptor;
+
+class Receiver : public ACE_Service_Handler
+{
+ friend class Acceptor;
+public:
+ Receiver (Acceptor *acceptor = 0, int index = -1);
+ ~Receiver (void);
+
+ size_t get_total_snd (void) { return this->total_snd_; }
+ size_t get_total_rcv (void) { return this->total_rcv_; }
+ long get_total_w (void) { return this->total_w_; }
+ long get_total_r (void) { return this->total_r_; }
+
+ // This is called to pass the new connection's addresses.
+ virtual void addresses (const ACE_INET_Addr& peer,
+ const ACE_INET_Addr& local);
+
+ /// This is called after the new connection has been accepted.
+ virtual void open (ACE_HANDLE handle,
+ ACE_Message_Block &message_block);
+
+protected:
+ /**
+ * @name AIO callback handling
+ *
+ * These methods are called by the framework
+ */
+ /// This is called when asynchronous <read> operation from the
+ /// socket completes.
+ virtual void handle_read_stream (const ACE_Asynch_Read_Stream::Result &result);
+
+ /// This is called when an asynchronous <write> to the socket
+ /// completes.
+ virtual void handle_write_stream (const ACE_Asynch_Write_Stream::Result &result);
+
+private:
+ int initiate_read_stream (void);
+ int initiate_write_stream (ACE_Message_Block &mb, size_t nbytes);
+ void cancel ();
+
+ Acceptor *acceptor_;
+ int index_;
+
+ ACE_Asynch_Read_Stream rs_;
+ ACE_Asynch_Write_Stream ws_;
+ ACE_HANDLE handle_;
+ ACE_SYNCH_MUTEX lock_;
+
+ long io_count_; // Number of currently outstanding I/O requests
+ int flg_cancel_;
+ size_t total_snd_; // Number of bytes successfully sent
+ size_t total_rcv_; // Number of bytes successfully received
+ long total_w_; // Number of write operations
+ long total_r_; // Number of read operations
+};
+
+// *******************************************
+// Sender
+// *******************************************
+
+class Connector;
+
+class Sender : public ACE_Service_Handler
+{
+ friend class Connector;
+public:
+
+ /// This is called after the new connection has been established.
+ virtual void open (ACE_HANDLE handle,
+ ACE_Message_Block &message_block);
+
+ Sender (Connector *connector = 0, int index = -1);
+ ~Sender (void);
+
+ size_t get_total_snd (void) { return this->total_snd_; }
+ size_t get_total_rcv (void) { return this->total_rcv_; }
+ long get_total_w (void) { return this->total_w_; }
+ long get_total_r (void) { return this->total_r_; }
+
+ // This is called to pass the new connection's addresses.
+ virtual void addresses (const ACE_INET_Addr& peer,
+ const ACE_INET_Addr& local);
+
+ virtual void handle_read_stream (const ACE_Asynch_Read_Stream::Result &result);
+ // This is called when asynchronous reads from the socket complete
+
+ virtual void handle_write_stream (const ACE_Asynch_Write_Stream::Result &result);
+ // This is called when asynchronous writes from the socket complete
+
+private:
+ int initiate_read_stream (void);
+ int initiate_write_stream (void);
+ void cancel (void);
+ void close (void);
+
+ int index_;
+ Connector * connector_;
+
+ ACE_Asynch_Read_Stream rs_;
+ ACE_Asynch_Write_Stream ws_;
+ ACE_HANDLE handle_;
+
+ ACE_SYNCH_MUTEX lock_;
+
+ long io_count_;
+ int stop_writing_; // Writes are shut down; just read.
+ int flg_cancel_;
+ size_t total_snd_;
+ size_t total_rcv_;
+ long total_w_;
+ long total_r_;
+};
+
+#endif /* ACE_TESTS_PROACTOR_TEST_H */