]> git.saurik.com Git - wxWidgets.git/commitdiff
replaced wxFDIODispatcher::RunLoop() with Dispatch() which handles only one event...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 14 Jul 2007 19:50:38 +0000 (19:50 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 14 Jul 2007 19:50:38 +0000 (19:50 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47470 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/private/fdiodispatcher.h
include/wx/private/selectdispatcher.h
include/wx/unix/private/epolldispatcher.h
src/common/selectdispatcher.cpp
src/unix/epolldispatcher.cpp

index 40e9982e23499b7cba0ac4805b8307dab558d23f..52e8efba7bc6473bffc0075fb642fe2efcbf6e52 100644 (file)
@@ -55,8 +55,8 @@ public:
     // unregister descriptor previously registered with RegisterFD()
     virtual bool UnregisterFD(int fd) = 0;
 
-    // loops waiting for an event to happen on any of the descriptors
-    virtual void RunLoop(int timeout) = 0;
+    // wait for an event for at most timeout milliseconds and process it
+    virtual void Dispatch(int timeout = TIMEOUT_INFINITE) = 0;
 
     virtual ~wxFDIODispatcher() { }
 };
index fac5f228447a9d0ca890d7427105d46f05b23b43..d61f0daf7786dd4605fc2f8a2dd71c3f3e9aaa1e 100644 (file)
@@ -89,7 +89,7 @@ public:
     virtual bool RegisterFD(int fd, wxFDIOHandler *handler, int flags = wxFDIO_ALL);
     virtual bool ModifyFD(int fd, wxFDIOHandler *handler, int flags = wxFDIO_ALL);
     virtual bool UnregisterFD(int fd);
-    virtual void RunLoop(int timeout = TIMEOUT_INFINITE);
+    virtual void Dispatch(int timeout = TIMEOUT_INFINITE);
 
 protected:
     wxSelectDispatcher();
index 735ab6d72cd0019598f59d1996474ba52fbf573b..c42b40f0a48ae65f4cfc81e80f5b342ba9a7cb2c 100644 (file)
@@ -30,7 +30,7 @@ public:
     virtual bool RegisterFD(int fd, wxFDIOHandler* handler, int flags = wxFDIO_ALL);
     virtual bool ModifyFD(int fd, wxFDIOHandler* handler, int flags = wxFDIO_ALL);
     virtual bool UnregisterFD(int fd);
-    virtual void RunLoop(int timeout = TIMEOUT_INFINITE);
+    virtual void Dispatch(int timeout = TIMEOUT_INFINITE);
 
 private:
     // ctor is private, use Get()
index 02c95710b73c817be73bb1bcd2c0646ddc174e18..654eee9f4a028c96871860dfb8e64f0364ee0366 100644 (file)
@@ -23,7 +23,6 @@
 
 #include "wx/private/selectdispatcher.h"
 #include "wx/module.h"
-#include "wx/timer.h"
 #include "wx/unix/private.h"
 
 #ifndef WX_PRECOMP
@@ -152,7 +151,7 @@ wxSelectDispatcher *wxSelectDispatcher::Get()
 void wxSelectDispatcher::DispatchPending()
 {
     if ( gs_selectDispatcher )
-        gs_selectDispatcher->RunLoop(0);
+        gs_selectDispatcher->Dispatch(0);
 }
 
 wxSelectDispatcher::wxSelectDispatcher()
@@ -229,53 +228,39 @@ void wxSelectDispatcher::ProcessSets(const wxSelectSets& sets)
     }
 }
 
-void wxSelectDispatcher::RunLoop(int timeout)
+void wxSelectDispatcher::Dispatch(int timeout)
 {
     struct timeval tv,
-                  *ptv = NULL;
+                  *ptv;
     if ( timeout != TIMEOUT_INFINITE )
     {
         ptv = &tv;
         tv.tv_sec = 0;
         tv.tv_usec = timeout*1000;
     }
-
-    for ( ;; )
+    else // no timeout
     {
-        wxSelectSets sets = m_sets;
+        ptv = NULL;
+    }
 
-        wxStopWatch sw;
-        if ( ptv && timeout )
-          sw.Start(ptv->tv_usec/10);
+    wxSelectSets sets = m_sets;
 
-        const int ret = sets.Select(m_maxFD + 1, ptv);
-        switch ( ret )
-        {
-            case -1:
-                // continue if we were interrupted by a signal, else bail out
-                if ( errno != EINTR )
-                {
-                    wxLogSysError(_("Failed to monitor I/O channels"));
-                    return;
-                }
-                break;
-
-            case 0:
-                // timeout expired without anything happening
-                return;
-
-            default:
-                ProcessSets(sets);
-        }
+    const int ret = sets.Select(m_maxFD + 1, ptv);
+    switch ( ret )
+    {
+        case -1:
+            if ( errno != EINTR )
+            {
+                wxLogSysError(_("Failed to monitor I/O channels"));
+            }
+            break;
 
-        if ( ptv )
-        {
-            timeout -= sw.Time();
-            if ( timeout <= 0 )
-                break;
+        case 0:
+            // timeout expired without anything happening
+            break;
 
-            ptv->tv_usec = timeout*1000;
-        }
+        default:
+            ProcessSets(sets);
     }
 }
 
index 9f8505cae7fd7bb1fe6a0d9a57f8f5b5114cd4f2..16ec914ad6a2019af69bdb3274a2d33c417abcba 100644 (file)
@@ -135,7 +135,7 @@ bool wxEpollDispatcher::UnregisterFD(int fd)
     return true;
 }
 
-void wxEpollDispatcher::RunLoop(int timeout)
+void wxEpollDispatcher::Dispatch(int timeout)
 {
     epoll_event events[16];
 
@@ -168,11 +168,9 @@ void wxEpollDispatcher::RunLoop(int timeout)
 
         if ( p->events & EPOLLIN )
             handler->OnReadWaiting();
-
-        if ( p->events & EPOLLOUT )
+        else if ( p->events & EPOLLOUT )
             handler->OnWriteWaiting();
-
-        if ( p->events & (EPOLLERR | EPOLLHUP) )
+        else if ( p->events & (EPOLLERR | EPOLLHUP) )
             handler->OnExceptionWaiting();
     }
 }