]> git.saurik.com Git - wxWidgets.git/blob - include/wx/unix/evtloop.h
trying to resolve GSocketManager API mess: the meaning of Install/Uninstall_Callback...
[wxWidgets.git] / include / wx / unix / evtloop.h
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 // RCS-ID: $Id$
7 // Copyright: (c) 2007 Lukasz Michalski
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_UNIX_EVTLOOP_H_
12 #define _WX_UNIX_EVTLOOP_H_
13
14 #if wxUSE_CONSOLE_EVENTLOOP
15
16 #include "wx/private/fdiodispatcher.h"
17 #include "wx/unix/pipe.h"
18
19 // ----------------------------------------------------------------------------
20 // wxEventLoop
21 // ----------------------------------------------------------------------------
22
23 class WXDLLIMPEXP_BASE wxConsoleEventLoop : public wxEventLoopManual
24 {
25 public:
26 // initialize the event loop, use IsOk() to check if we were successful
27 wxConsoleEventLoop();
28
29 // implement base class pure virtuals
30 virtual bool Pending() const;
31 virtual bool Dispatch();
32 virtual void WakeUp();
33 virtual bool IsOk() const { return m_dispatcher != NULL; }
34
35 protected:
36 virtual void OnNextIteration();
37
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 class PipeIOHandler : public wxFDIOHandler
42 {
43 public:
44 // default ctor does nothing, call Create() to really initialize the
45 // object
46 PipeIOHandler() { }
47
48 bool Create();
49
50 // this method can be, and normally is, called from another thread
51 void WakeUp();
52
53 int GetReadFd() { return m_pipe[wxPipe::Read]; }
54
55 // implement wxFDIOHandler pure virtual methods
56 virtual void OnReadWaiting();
57 virtual void OnWriteWaiting() { }
58 virtual void OnExceptionWaiting() { }
59
60 private:
61 wxPipe m_pipe;
62 };
63
64 PipeIOHandler m_wakeupPipe;
65
66 // either wxSelectDispatcher or wxEpollDispatcher
67 wxFDIODispatcher *m_dispatcher;
68
69 DECLARE_NO_COPY_CLASS(wxConsoleEventLoop)
70 };
71
72 #endif // wxUSE_CONSOLE_EVENTLOOP
73
74 #endif // _WX_UNIX_EVTLOOP_H_