evtloop.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/unix/evtloop.h
  3. // Purpose: declares wxEventLoop class
  4. // Author: Lukasz Michalski (lm@zork.pl)
  5. // Created: 2007-05-07
  6. // Copyright: (c) 2007 Lukasz Michalski
  7. // Licence: wxWindows licence
  8. ///////////////////////////////////////////////////////////////////////////////
  9. #ifndef _WX_UNIX_EVTLOOP_H_
  10. #define _WX_UNIX_EVTLOOP_H_
  11. #if wxUSE_CONSOLE_EVENTLOOP
  12. // ----------------------------------------------------------------------------
  13. // wxConsoleEventLoop
  14. // ----------------------------------------------------------------------------
  15. class wxEventLoopSource;
  16. class wxFDIODispatcher;
  17. class wxWakeUpPipeMT;
  18. class WXDLLIMPEXP_BASE wxConsoleEventLoop
  19. #ifdef __WXOSX__
  20. : public wxCFEventLoop
  21. #else
  22. : public wxEventLoopManual
  23. #endif
  24. {
  25. public:
  26. // initialize the event loop, use IsOk() to check if we were successful
  27. wxConsoleEventLoop();
  28. virtual ~wxConsoleEventLoop();
  29. // implement base class pure virtuals
  30. virtual bool Pending() const;
  31. virtual bool Dispatch();
  32. virtual int DispatchTimeout(unsigned long timeout);
  33. virtual void WakeUp();
  34. virtual bool IsOk() const { return m_dispatcher != NULL; }
  35. virtual bool YieldFor(long WXUNUSED(eventsToProcess)) { return true; }
  36. protected:
  37. virtual void OnNextIteration();
  38. private:
  39. // pipe used for wake up messages: when a child thread wants to wake up
  40. // the event loop in the main thread it writes to this pipe
  41. wxWakeUpPipeMT *m_wakeupPipe;
  42. // the event loop source used to monitor this pipe
  43. wxEventLoopSource* m_wakeupSource;
  44. // either wxSelectDispatcher or wxEpollDispatcher
  45. wxFDIODispatcher *m_dispatcher;
  46. wxDECLARE_NO_COPY_CLASS(wxConsoleEventLoop);
  47. };
  48. #endif // wxUSE_CONSOLE_EVENTLOOP
  49. #endif // _WX_UNIX_EVTLOOP_H_