]> git.saurik.com Git - wxWidgets.git/blame - include/wx/unix/evtloop.h
removed broken and global GetLine() function from wx/protocol/protocol.h; there's...
[wxWidgets.git] / include / wx / unix / evtloop.h
CommitLineData
b46b1d59
VZ
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#include "wx/private/fdiodispatcher.h"
b46b1d59
VZ
15#include "wx/unix/pipe.h"
16
17// ----------------------------------------------------------------------------
18// wxEventLoop
19// ----------------------------------------------------------------------------
20
21class WXDLLIMPEXP_BASE wxConsoleEventLoop : public wxEventLoopManual
22{
23public:
24 // initialize the event loop, use IsOk() to check if we were successful
25 wxConsoleEventLoop();
26
27 // implement base class pure virtuals
28 virtual bool Pending() const;
29 virtual bool Dispatch();
30 virtual void WakeUp();
31 virtual bool IsOk() const { return m_dispatcher != NULL; }
32
33protected:
34 virtual void OnNextIteration();
35
36private:
37 // pipe used for wake up messages: when a child thread wants to wake up
38 // the event loop in the main thread it writes to this pipe
39 class PipeIOHandler : public wxFDIOHandler
40 {
41 public:
42 // default ctor does nothing, call Create() to really initialize the
43 // object
44 PipeIOHandler() { }
45
46 bool Create();
47
48 // this method can be, and normally is, called from another thread
49 void WakeUp();
50
51 int GetReadFd() { return m_pipe[wxPipe::Read]; }
52
53 // implement wxFDIOHandler pure virtual methods
54 virtual void OnReadWaiting();
55 virtual void OnWriteWaiting() { }
56 virtual void OnExceptionWaiting() { }
57
58 private:
59 wxPipe m_pipe;
60 };
61
62 PipeIOHandler m_wakeupPipe;
63
64 // either wxSelectDispatcher or wxEpollDispatcher
65 wxFDIODispatcher *m_dispatcher;
66
67 DECLARE_NO_COPY_CLASS(wxConsoleEventLoop)
68};
69
70#endif // _WX_UNIX_EVTLOOP_H_