summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Stitcher <astitcher@apache.org>2008-08-11 16:00:43 +0000
committerAndrew Stitcher <astitcher@apache.org>2008-08-11 16:00:43 +0000
commit5c2e3052815e76e7565038f771cdb235e0516816 (patch)
tree8e92fb3bf59c674f2cfc3d9d394b6210a3ff8ebb
parent48f393f2de21815662ee13c86ebe3a9c2f5627d7 (diff)
downloadqpid-python-5c2e3052815e76e7565038f771cdb235e0516816.tar.gz
Decouple the DispatchHandle from its clients by using a
DispatchHandleRef class which can be deleted at any time, but will only cause the DispatchHandle to be deleted later when it's definitely no longer in use. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@684787 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--cpp/src/qpid/sys/Dispatcher.h26
1 files changed, 24 insertions, 2 deletions
diff --git a/cpp/src/qpid/sys/Dispatcher.h b/cpp/src/qpid/sys/Dispatcher.h
index 77a205cc8b..68661e81aa 100644
--- a/cpp/src/qpid/sys/Dispatcher.h
+++ b/cpp/src/qpid/sys/Dispatcher.h
@@ -36,9 +36,9 @@
namespace qpid {
namespace sys {
-class Dispatcher;
+class DispatchHandleRef;
class DispatchHandle : public PollerHandle {
- friend class Dispatcher;
+ friend class DispatchHandleRef;
public:
typedef boost::function1<void, DispatchHandle&> Callback;
@@ -81,6 +81,28 @@ private:
void processEvent(Poller::EventType dir);
};
+class DispatchHandleRef {
+ DispatchHandle* ref;
+
+public:
+ typedef boost::function1<void, DispatchHandle&> Callback;
+ DispatchHandleRef(const IOHandle& h, Callback rCb, Callback wCb, Callback dCb) :
+ ref(new DispatchHandle(h, rCb, wCb, dCb))
+ {}
+
+ ~DispatchHandleRef() { ref->doDelete(); }
+
+ void startWatch(Poller::shared_ptr poller) { ref->startWatch(poller); }
+ void rewatch() { ref->rewatch(); }
+ void rewatchRead() { ref->rewatchRead(); }
+ void rewatchWrite() { ref->rewatchWrite(); }
+ void unwatch() { ref->unwatch(); }
+ void unwatchRead() { ref->unwatchRead(); }
+ void unwatchWrite() { ref->unwatchWrite(); }
+ void stopWatch() { ref->stopWatch(); }
+};
+
+
class Dispatcher : public Runnable {
const Poller::shared_ptr poller;