X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/22b6de6a70900550b5411f14fffc9d48adbbf222..0e08dd802b39ca3732a4797ab43a4461c8397889:/src/common/selectdispatcher.cpp diff --git a/src/common/selectdispatcher.cpp b/src/common/selectdispatcher.cpp index 138fa3cc8c..990b62c21c 100644 --- a/src/common/selectdispatcher.cpp +++ b/src/common/selectdispatcher.cpp @@ -30,7 +30,8 @@ #include "wx/intl.h" #endif -#ifdef HAVE_SYS_SELECT_H +#if defined(HAVE_SYS_SELECT_H) || defined(__WATCOMC__) + #include #include #endif @@ -119,8 +120,8 @@ void wxSelectSets::Handle(int fd, wxFDIOHandler& handler) const wxLogTrace(wxSelectDispatcher_Trace, _T("Got %s event on fd %d"), ms_names[n], fd); (handler.*ms_handlers[n])(); - // callback can modify sets and destroy handler, returning from - // here guarantees that one event is processed at a time + // callback can modify sets and destroy handler + // this forces that one event can be processed at one time return; } } @@ -130,17 +131,6 @@ void wxSelectSets::Handle(int fd, wxFDIOHandler& handler) const // wxSelectDispatcher // ---------------------------------------------------------------------------- -/* static */ -wxSelectDispatcher *wxSelectDispatcher::Create() -{ - return new wxSelectDispatcher; -} - -wxSelectDispatcher::wxSelectDispatcher() -{ - m_maxFD = -1; -} - bool wxSelectDispatcher::RegisterFD(int fd, wxFDIOHandler *handler, int flags) { if ( !wxMappedFDIODispatcher::RegisterFD(fd, handler, flags) ) @@ -200,8 +190,9 @@ bool wxSelectDispatcher::UnregisterFD(int fd) return true; } -void wxSelectDispatcher::ProcessSets(const wxSelectSets& sets) +bool wxSelectDispatcher::ProcessSets(const wxSelectSets& sets) { + bool gotEvent = false; for ( int fd = 0; fd <= m_maxFD; fd++ ) { if ( !sets.HasFD(fd) ) @@ -214,11 +205,15 @@ void wxSelectDispatcher::ProcessSets(const wxSelectSets& sets) continue; } + gotEvent = true; + sets.Handle(fd, *handler); } + + return gotEvent; } -void wxSelectDispatcher::Dispatch(int timeout) +bool wxSelectDispatcher::Dispatch(int timeout) { struct timeval tv, *ptv; @@ -250,8 +245,12 @@ void wxSelectDispatcher::Dispatch(int timeout) break; default: - ProcessSets(sets); + if ( ProcessSets(sets) ) + return true; } + + // nothing happened + return false; } #endif // wxUSE_SELECT_DISPATCHER