]> git.saurik.com Git - wxWidgets.git/blob - include/wx/unix/evtloop.h
Refactor wxEventLoopSource-related code.
[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 class wxUnixEventLoopSource;
22
23 namespace wxPrivate
24 {
25 class PipeIOHandler;
26 }
27
28 class WXDLLIMPEXP_BASE wxConsoleEventLoop : public wxEventLoopManual
29 {
30 public:
31 // initialize the event loop, use IsOk() to check if we were successful
32 wxConsoleEventLoop();
33 virtual ~wxConsoleEventLoop();
34
35 // implement base class pure virtuals
36 virtual bool Pending() const;
37 virtual bool Dispatch();
38 virtual int DispatchTimeout(unsigned long timeout);
39 virtual void WakeUp();
40 virtual bool IsOk() const { return m_dispatcher != NULL; }
41 virtual bool YieldFor(long WXUNUSED(eventsToProcess)) { return true; }
42
43 #if wxUSE_EVENTLOOP_SOURCE
44 virtual wxEventLoopSource *
45 AddSourceForFD(int fd, wxEventLoopSourceHandler *handler, int flags);
46 #endif // wxUSE_EVENTLOOP_SOURCE
47
48 protected:
49 virtual void OnNextIteration();
50
51 private:
52 // pipe used for wake up messages: when a child thread wants to wake up
53 // the event loop in the main thread it writes to this pipe
54 wxPrivate::PipeIOHandler *m_wakeupPipe;
55
56 // either wxSelectDispatcher or wxEpollDispatcher
57 wxFDIODispatcher *m_dispatcher;
58
59 wxDECLARE_NO_COPY_CLASS(wxConsoleEventLoop);
60 };
61
62 #endif // wxUSE_CONSOLE_EVENTLOOP
63
64 #endif // _WX_UNIX_EVTLOOP_H_