1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/unix/evtloop.h
3 // Purpose: declares wxEventLoop class
4 // Author: Lukasz Michalski (lm@zork.pl)
7 // Copyright: (c) 2007 Lukasz Michalski
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 #ifndef _WX_UNIX_EVTLOOP_H_
12 #define _WX_UNIX_EVTLOOP_H_
14 #if wxUSE_CONSOLE_EVENTLOOP
16 #include "wx/private/fdiodispatcher.h"
17 #include "wx/unix/pipe.h"
19 // ----------------------------------------------------------------------------
21 // ----------------------------------------------------------------------------
23 class WXDLLIMPEXP_BASE wxConsoleEventLoop
: public wxEventLoopManual
26 // initialize the event loop, use IsOk() to check if we were successful
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
; }
37 virtual void OnNextIteration();
40 // pipe used for wake up messages: when a child thread wants to wake up
41 // the event loop in the main thread it writes to this pipe
42 class PipeIOHandler
: public wxFDIOHandler
45 // default ctor does nothing, call Create() to really initialize the
51 // this method can be, and normally is, called from another thread
54 int GetReadFd() { return m_pipe
[wxPipe::Read
]; }
56 // implement wxFDIOHandler pure virtual methods
57 virtual void OnReadWaiting();
58 virtual void OnWriteWaiting() { }
59 virtual void OnExceptionWaiting() { }
65 PipeIOHandler m_wakeupPipe
;
67 // either wxSelectDispatcher or wxEpollDispatcher
68 wxFDIODispatcher
*m_dispatcher
;
70 DECLARE_NO_COPY_CLASS(wxConsoleEventLoop
)
73 #endif // wxUSE_CONSOLE_EVENTLOOP
75 #endif // _WX_UNIX_EVTLOOP_H_