git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@56355
c3d73ce0-8a6f-49c7-b76d-
6d57e0e08775
// unregister descriptor previously registered with RegisterFD()
virtual bool UnregisterFD(int fd) = 0;
// unregister descriptor previously registered with RegisterFD()
virtual bool UnregisterFD(int fd) = 0;
- // wait for an event for at most timeout milliseconds and process it
- virtual void Dispatch(int timeout = TIMEOUT_INFINITE) = 0;
+ // wait for an event for at most timeout milliseconds and process it;
+ // return true if we processed any events or false if timeout expired
+ // without anything happening
+ virtual bool Dispatch(int timeout = TIMEOUT_INFINITE) = 0;
virtual ~wxFDIODispatcher() { }
};
virtual ~wxFDIODispatcher() { }
};
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 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 Dispatch(int timeout = TIMEOUT_INFINITE);
+ virtual bool Dispatch(int timeout = TIMEOUT_INFINITE);
private:
// common part of RegisterFD() and ModifyFD()
bool DoUpdateFDAndHandler(int fd, wxFDIOHandler *handler, int flags);
private:
// common part of RegisterFD() and ModifyFD()
bool DoUpdateFDAndHandler(int fd, wxFDIOHandler *handler, int flags);
- // call the handlers for the fds present in the given sets
- void ProcessSets(const wxSelectSets& sets);
+ // call the handlers for the fds present in the given sets, return true if
+ // we called any handlers
+ bool ProcessSets(const wxSelectSets& sets);
// helper of ProcessSets(): call the handler if its fd is in the set
void DoProcessFD(int fd, const fd_set& fds, wxFDIOHandler *handler,
// helper of ProcessSets(): call the handler if its fd is in the set
void DoProcessFD(int fd, const fd_set& fds, wxFDIOHandler *handler,
-void wxSelectDispatcher::ProcessSets(const wxSelectSets& sets)
+bool wxSelectDispatcher::ProcessSets(const wxSelectSets& sets)
for ( int fd = 0; fd <= m_maxFD; fd++ )
{
if ( !sets.HasFD(fd) )
for ( int fd = 0; fd <= m_maxFD; fd++ )
{
if ( !sets.HasFD(fd) )
sets.Handle(fd, *handler);
}
sets.Handle(fd, *handler);
}
-void wxSelectDispatcher::Dispatch(int timeout)
+bool wxSelectDispatcher::Dispatch(int timeout)
{
struct timeval tv,
*ptv;
{
struct timeval tv,
*ptv;
+ if ( ProcessSets(sets) )
+ return true;
+
+ // nothing happened
+ return false;
}
#endif // wxUSE_SELECT_DISPATCHER
}
#endif // wxUSE_SELECT_DISPATCHER
-void wxEpollDispatcher::Dispatch(int timeout)
+bool wxEpollDispatcher::Dispatch(int timeout)
{
epoll_event events[16];
{
epoll_event events[16];
{
wxLogSysError(_("Waiting for IO on epoll descriptor %d failed"),
m_epollDescriptor);
{
wxLogSysError(_("Waiting for IO on epoll descriptor %d failed"),
m_epollDescriptor);
+ bool gotEvents = false;
for ( epoll_event *p = events; p < events + e_num; p++ )
{
wxFDIOHandler * const handler = (wxFDIOHandler *)(p->data.ptr);
for ( epoll_event *p = events; p < events + e_num; p++ )
{
wxFDIOHandler * const handler = (wxFDIOHandler *)(p->data.ptr);
handler->OnWriteWaiting();
else if ( p->events & EPOLLERR )
handler->OnExceptionWaiting();
handler->OnWriteWaiting();
else if ( p->events & EPOLLERR )
handler->OnExceptionWaiting();
+ else
+ continue;
+
+ gotEvents = true;
}
#endif // wxUSE_EPOLL_DISPATCHER
}
#endif // wxUSE_EPOLL_DISPATCHER