You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by as...@apache.org on 2008/08/11 18:00:44 UTC

svn commit: r684787 - /incubator/qpid/trunk/qpid/cpp/src/qpid/sys/Dispatcher.h

Author: astitcher
Date: Mon Aug 11 09:00:43 2008
New Revision: 684787

URL: http://svn.apache.org/viewvc?rev=684787&view=rev
Log:
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.

Modified:
    incubator/qpid/trunk/qpid/cpp/src/qpid/sys/Dispatcher.h

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/sys/Dispatcher.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/sys/Dispatcher.h?rev=684787&r1=684786&r2=684787&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/sys/Dispatcher.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/sys/Dispatcher.h Mon Aug 11 09:00:43 2008
@@ -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 @@
     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;