]> git.saurik.com Git - wxWidgets.git/blob - include/wx/unix/evtloop.h
35d918390c6547bc9cea9946c873ba6a21547535
[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 // ----------------------------------------------------------------------------
17 // wxConsoleEventLoop
18 // ----------------------------------------------------------------------------
19
20 class wxFDIODispatcher;
21
22 namespace wxPrivate
23 {
24 class PipeIOHandler;
25 }
26
27 class WXDLLIMPEXP_BASE wxConsoleEventLoop : public wxEventLoopManual
28 {
29 public:
30 typedef wxUnixEventLoopSource Source;
31
32 // initialize the event loop, use IsOk() to check if we were successful
33 wxConsoleEventLoop();
34 virtual ~wxConsoleEventLoop();
35
36 // implement base class pure virtuals
37 virtual bool Pending() const;
38 virtual bool Dispatch();
39 virtual int DispatchTimeout(unsigned long timeout);
40 virtual void WakeUp();
41 virtual bool IsOk() const { return m_dispatcher != NULL; }
42 virtual bool YieldFor(long WXUNUSED(eventsToProcess)) { return true; }
43
44 #if wxUSE_EVENTLOOP_SOURCE
45 virtual wxUnixEventLoopSource* CreateSource() const
46 {
47 return new wxUnixEventLoopSource();
48 }
49
50 virtual wxUnixEventLoopSource* CreateSource(int res,
51 wxEventLoopSourceHandler* handler,
52 int flags) const
53 {
54 return new wxUnixEventLoopSource(res, handler, flags);
55 }
56 #endif
57
58 protected:
59 #if wxUSE_EVENTLOOP_SOURCE
60 // adding/removing sources
61 virtual bool DoAddSource(wxAbstractEventLoopSource* source);
62 virtual bool DoRemoveSource(wxAbstractEventLoopSource* source);
63 #endif
64
65 virtual void OnNextIteration();
66
67 private:
68 // pipe used for wake up messages: when a child thread wants to wake up
69 // the event loop in the main thread it writes to this pipe
70 wxPrivate::PipeIOHandler *m_wakeupPipe;
71
72 // either wxSelectDispatcher or wxEpollDispatcher
73 wxFDIODispatcher *m_dispatcher;
74
75 wxDECLARE_NO_COPY_CLASS(wxConsoleEventLoop);
76 };
77
78 #endif // wxUSE_CONSOLE_EVENTLOOP
79
80 #endif // _WX_UNIX_EVTLOOP_H_