summaryrefslogtreecommitdiff
path: root/cpp/src/qpid/sys/AsynchIO.h
diff options
context:
space:
mode:
authorAndrew Stitcher <astitcher@apache.org>2008-05-09 02:00:04 +0000
committerAndrew Stitcher <astitcher@apache.org>2008-05-09 02:00:04 +0000
commit2d4d4a1425d3f4e189868d36a0cc9fbd4bec4756 (patch)
tree7413a08c12494e5c5551b3f09ad35f29804d66a3 /cpp/src/qpid/sys/AsynchIO.h
parent266fbd3880a49ea4f6a221231027408a32033687 (diff)
downloadqpid-python-2d4d4a1425d3f4e189868d36a0cc9fbd4bec4756.tar.gz
QPID-1040: Patch from Ted Ross: Asynchronous Connector
Code to allow non-blocking connection of new sockets git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@654666 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/sys/AsynchIO.h')
-rw-r--r--cpp/src/qpid/sys/AsynchIO.h29
1 files changed, 28 insertions, 1 deletions
diff --git a/cpp/src/qpid/sys/AsynchIO.h b/cpp/src/qpid/sys/AsynchIO.h
index 13bed78e85..847bdc50e4 100644
--- a/cpp/src/qpid/sys/AsynchIO.h
+++ b/cpp/src/qpid/sys/AsynchIO.h
@@ -52,7 +52,34 @@ private:
};
/*
- * Asycnchronous reader/writer:
+ * Asynchronous connector: starts the process of initiating a connection and
+ * invokes a callback when completed or failed.
+ */
+class AsynchConnector : private DispatchHandle {
+public:
+ typedef boost::function1<void, const Socket&> ConnectedCallback;
+ typedef boost::function2<void, int, std::string> FailedCallback;
+
+private:
+ ConnectedCallback connCallback;
+ FailedCallback failCallback;
+ const Socket& socket;
+
+public:
+ AsynchConnector(const Socket& socket,
+ Poller::shared_ptr poller,
+ std::string hostname,
+ uint16_t port,
+ ConnectedCallback connCb,
+ FailedCallback failCb = 0);
+
+private:
+ void connComplete(DispatchHandle& handle);
+ void failure(int, std::string);
+};
+
+/*
+ * Asychronous reader/writer:
* Reader accepts buffers to read into; reads into the provided buffers
* and then does a callback with the buffer and amount read. Optionally it can callback
* when there is something to read but no buffer to read it into.