epolldispatcher.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/unix/private/epolldispatcher.h
  3. // Purpose: wxEpollDispatcher class
  4. // Authors: Lukasz Michalski
  5. // Created: April 2007
  6. // Copyright: (c) Lukasz Michalski
  7. // Licence: wxWindows licence
  8. /////////////////////////////////////////////////////////////////////////////
  9. #ifndef _WX_PRIVATE_EPOLLDISPATCHER_H_
  10. #define _WX_PRIVATE_EPOLLDISPATCHER_H_
  11. #include "wx/defs.h"
  12. #ifdef wxUSE_EPOLL_DISPATCHER
  13. #include "wx/private/fdiodispatcher.h"
  14. struct epoll_event;
  15. class WXDLLIMPEXP_BASE wxEpollDispatcher : public wxFDIODispatcher
  16. {
  17. public:
  18. // create a new instance of this class, can return NULL if
  19. // epoll() is not supported on this system
  20. //
  21. // the caller should delete the returned pointer
  22. static wxEpollDispatcher *Create();
  23. virtual ~wxEpollDispatcher();
  24. // implement base class pure virtual methods
  25. virtual bool RegisterFD(int fd, wxFDIOHandler* handler, int flags = wxFDIO_ALL);
  26. virtual bool ModifyFD(int fd, wxFDIOHandler* handler, int flags = wxFDIO_ALL);
  27. virtual bool UnregisterFD(int fd);
  28. virtual bool HasPending() const;
  29. virtual int Dispatch(int timeout = TIMEOUT_INFINITE);
  30. private:
  31. // ctor is private, use Create()
  32. wxEpollDispatcher(int epollDescriptor);
  33. // common part of HasPending() and Dispatch(): calls epoll_wait() with the
  34. // given timeout
  35. int DoPoll(epoll_event *events, int numEvents, int timeout) const;
  36. int m_epollDescriptor;
  37. };
  38. #endif // wxUSE_EPOLL_DISPATCHER
  39. #endif // _WX_PRIVATE_SOCKETEVTDISPATCH_H_