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/07/24 07:31:07 UTC

svn commit: r679276 - in /incubator/qpid/trunk/qpid/cpp/src/qpid/sys: Dispatcher.cpp Dispatcher.h Poller.h

Author: astitcher
Date: Wed Jul 23 22:31:07 2008
New Revision: 679276

URL: http://svn.apache.org/viewvc?rev=679276&view=rev
Log:
Refactored so that Dispatcher is now independent from DispatchHandle

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

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/sys/Dispatcher.cpp
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/sys/Dispatcher.cpp?rev=679276&r1=679275&r2=679276&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/sys/Dispatcher.cpp (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/sys/Dispatcher.cpp Wed Jul 23 22:31:07 2008
@@ -38,12 +38,10 @@
 void Dispatcher::run() {
     do {
         Poller::Event event = poller->wait();
-        DispatchHandle* h =
-            boost::polymorphic_downcast<DispatchHandle*>(event.handle);
 
         // If can read/write then dispatch appropriate callbacks        
-        if (h) {
-            h->dispatchCallbacks(event.type);
+        if (event.handle) {
+            event.process();
         } else {
             // Handle shutdown
             switch (event.type) {
@@ -344,7 +342,7 @@
     deferDelete();
 }
 
-void DispatchHandle::dispatchCallbacks(Poller::EventType type) {
+void DispatchHandle::processEvent(Poller::EventType type) {
     // Note that we are now doing the callbacks
     {
     ScopedLock<Mutex> lock(stateLock);

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=679276&r1=679275&r2=679276&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/sys/Dispatcher.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/sys/Dispatcher.h Wed Jul 23 22:31:07 2008
@@ -78,7 +78,7 @@
     void doDelete();
 
 private:
-    void dispatchCallbacks(Poller::EventType dir);
+    void processEvent(Poller::EventType dir);
 };
 
 class Dispatcher : public Runnable {

Modified: incubator/qpid/trunk/qpid/cpp/src/qpid/sys/Poller.h
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/cpp/src/qpid/sys/Poller.h?rev=679276&r1=679275&r2=679276&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/cpp/src/qpid/sys/Poller.h (original)
+++ incubator/qpid/trunk/qpid/cpp/src/qpid/sys/Poller.h Wed Jul 23 22:31:07 2008
@@ -30,31 +30,10 @@
 namespace sys {
 
 /**
- * Handle class to use for polling
- */
-class IOHandle;
-class Poller;
-class PollerHandlePrivate;
-class PollerHandle {
-    friend class Poller;
-
-    PollerHandlePrivate* const impl;
-
-public:
-    PollerHandle(const IOHandle& h);
-    
-    // Usual way to delete (will defer deletion until we
-    // can't be returned from a Poller::wait any more)
-    void deferDelete();
-    
-    // Class clients shouldn't ever use this
-    virtual ~PollerHandle();
-};
-
-/**
  * Poller: abstract class to encapsulate a file descriptor poll to be used
  * by a reactor
  */
+class PollerHandle;
 class PollerPrivate;
 class Poller {
     PollerPrivate* const impl;
@@ -87,6 +66,8 @@
           handle(handle0),
           type(type0) {
         }
+        
+        void process();
     };
     
     Poller();
@@ -101,5 +82,32 @@
     Event wait(Duration timeout = TIME_INFINITE);
 };
 
+/**
+ * Handle class to use for polling
+ */
+class IOHandle;
+class PollerHandlePrivate;
+class PollerHandle {
+    friend class Poller;
+    friend struct Poller::Event;
+
+    PollerHandlePrivate* const impl;
+    virtual void processEvent(Poller::EventType) {};
+
+public:
+    PollerHandle(const IOHandle& h);
+    
+    // Usual way to delete (will defer deletion until we
+    // can't be returned from a Poller::wait any more)
+    void deferDelete();
+    
+    // Class clients shouldn't ever use this
+    virtual ~PollerHandle();
+};
+
+inline void Poller::Event::process() {
+            handle->processEvent(type);
+}
+
 }}
 #endif // _sys_Poller_h