added wxFDIODispatcher::HasPending() and implemented correctly wxConsoleEventLoop::Pending() using it to fix the pending events processing in console event loop based programs; also changed wxFDIODispatcher::Dispatch() return type/value to be able to indicate the errors

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57804 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-01-03 01:21:24 +00:00
parent 247b70c6c7
commit a12698abb7
6 changed files with 105 additions and 52 deletions

View File

@@ -56,8 +56,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)();
@@ -91,20 +92,25 @@ 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 bool Dispatch(int timeout = TIMEOUT_INFINITE);
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, return true if
// we called any handlers
bool 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;