diff options
author | Andrew Stitcher <astitcher@apache.org> | 2008-08-11 16:00:43 +0000 |
---|---|---|
committer | Andrew Stitcher <astitcher@apache.org> | 2008-08-11 16:00:43 +0000 |
commit | c4baeebcde0732be4bf530272fea50cd549cb070 (patch) | |
tree | df30acbbc01db52090505db3eb3a2256905c8e83 | |
parent | 8ebc7e8de7cb24c2d521473cb6a6f479c331936e (diff) | |
download | qpid-python-c4baeebcde0732be4bf530272fea50cd549cb070.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@684787 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | qpid/cpp/src/qpid/sys/Dispatcher.h | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/qpid/cpp/src/qpid/sys/Dispatcher.h b/qpid/cpp/src/qpid/sys/Dispatcher.h index 77a205cc8b..68661e81aa 100644 --- a/qpid/cpp/src/qpid/sys/Dispatcher.h +++ b/qpid/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; |