replaced wxFDIODispatcher::RunLoop() with Dispatch() which handles only one event at a time (part 1 of the patch 1733626)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47470 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -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() { }
|
||||
};
|
||||
|
@@ -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();
|
||||
|
@@ -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()
|
||||
|
@@ -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,54 +228,40 @@ 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;
|
||||
break;
|
||||
|
||||
default:
|
||||
ProcessSets(sets);
|
||||
}
|
||||
|
||||
if ( ptv )
|
||||
{
|
||||
timeout -= sw.Time();
|
||||
if ( timeout <= 0 )
|
||||
break;
|
||||
|
||||
ptv->tv_usec = timeout*1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user