+namespace wxPrivate
+{
+
+// pipe used for wake up messages: when a child thread wants to wake up
+// the event loop in the main thread it writes to this pipe
+class PipeIOHandler : public wxFDIOHandler
+{
+public:
+ // default ctor does nothing, call Create() to really initialize the
+ // object
+ PipeIOHandler() : m_pipeIsEmpty(true) { }
+
+ bool Create();
+
+ // this method can be, and normally is, called from another thread
+ void WakeUp();
+
+ int GetReadFd() { return m_pipe[wxPipe::Read]; }
+
+ // implement wxFDIOHandler pure virtual methods
+ virtual void OnReadWaiting();
+ virtual void OnWriteWaiting() { }
+ virtual void OnExceptionWaiting() { }
+
+private:
+ wxPipe m_pipe;
+
+ // Protects access to m_pipeIsEmpty.
+ wxCriticalSection m_pipeLock;
+
+ // This flag is set to true after writing to the pipe and reset to false
+ // after reading from it in the main thread. Having it allows us to avoid
+ // overflowing the pipe with too many writes if the main thread can't keep
+ // up with reading from it.
+ bool m_pipeIsEmpty;
+};
+