X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/b46b1d59d6f69ad80dcf5955375578a6504d100a..6968a3b87cee46f5c5af9b46e1ef97f17133cef7:/include/wx/private/selectdispatcher.h diff --git a/include/wx/private/selectdispatcher.h b/include/wx/private/selectdispatcher.h index cd86e15cd8..5c17fe650e 100644 --- a/include/wx/private/selectdispatcher.h +++ b/include/wx/private/selectdispatcher.h @@ -13,6 +13,21 @@ #include "wx/defs.h" +#if wxUSE_SELECT_DISPATCHER + +#if defined(HAVE_SYS_SELECT_H) || defined(__WATCOMC__) + #include + #include +#endif + +#ifdef __WATCOMC__ + #include + #include + #include +#else + #include +#endif + #include "wx/private/fdiodispatcher.h" // helper class storing all the select() fd sets @@ -34,9 +49,9 @@ public: // same as SetFD() except it unsets the bits set in the flags for the given // fd - bool ClearFD(int fd, int flags) + bool ClearFD(int fd) { - return SetFD(fd, wxFDIO_ALL & ~flags); + return SetFD(fd, 0); } @@ -44,8 +59,9 @@ public: // select() itself int Select(int nfds, struct timeval *tv); - // call the handler methods corresponding to the sets having this fd - void Handle(int fd, wxFDIOHandler& handler) const; + // call the handler methods corresponding to the sets having this fd if it + // is present in any set and return true if it is + bool Handle(int fd, wxFDIOHandler& handler) const; private: typedef void (wxFDIOHandler::*Callback)(); @@ -69,38 +85,35 @@ private: static Callback ms_handlers[Max]; }; -class WXDLLIMPEXP_BASE wxSelectDispatcher : public wxFDIODispatcher +class WXDLLIMPEXP_BASE wxSelectDispatcher : public wxMappedFDIODispatcher { public: - // returns the unique instance of this class, the pointer shouldn't be - // deleted and is normally never NULL - static wxSelectDispatcher *Get(); - - // if we have any registered handlers, check for any pending events to them - // and dispatch them -- this is used from wxX11 and wxDFB event loops - // implementation - static void DispatchPending(); + // default ctor + wxSelectDispatcher() { m_maxFD = -1; } // implement pure virtual methods of the base class virtual bool RegisterFD(int fd, wxFDIOHandler *handler, int flags = wxFDIO_ALL); virtual bool ModifyFD(int fd, wxFDIOHandler *handler, int flags = wxFDIO_ALL); - virtual wxFDIOHandler *UnregisterFD(int fd, int flags = wxFDIO_ALL); - virtual void RunLoop(int timeout = TIMEOUT_INFINITE); - -protected: - wxSelectDispatcher(); + virtual bool UnregisterFD(int fd); + virtual bool HasPending() const; + virtual int Dispatch(int timeout = TIMEOUT_INFINITE); 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 the + // number of handlers we called + int 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, const char *name); + // common part of HasPending() and Dispatch(): calls select() with the + // specified timeout + int DoSelect(wxSelectSets& sets, int timeout) const; + // the select sets containing all the registered fds wxSelectSets m_sets; @@ -109,5 +122,6 @@ private: int m_maxFD; }; +#endif // wxUSE_SELECT_DISPATCHER #endif // _WX_PRIVATE_SOCKETEVTDISPATCH_H_