Coverage Report

Created: 2026-11-12 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/wxwidgets/include/wx/unix/private/wakeuppipe.h
Line
Count
Source
1
///////////////////////////////////////////////////////////////////////////////
2
// Name:        wx/unix/private/wakeuppipe.h
3
// Purpose:     Helper class allowing to wake up the main thread.
4
// Author:      Vadim Zeitlin
5
// Created:     2013-06-09 (extracted from src/unix/evtloopunix.cpp)
6
// Copyright:   (c) 2013 Vadim Zeitlin <vadim@wxwidgets.org>
7
// Licence:     wxWindows licence
8
///////////////////////////////////////////////////////////////////////////////
9
10
#ifndef _WX_UNIX_PRIVATE_WAKEUPPIPE_H_
11
#define _WX_UNIX_PRIVATE_WAKEUPPIPE_H_
12
13
#include "wx/unix/pipe.h"
14
#include "wx/evtloopsrc.h"
15
16
// ----------------------------------------------------------------------------
17
// wxWakeUpPipe: allows to wake up the event loop by writing to it
18
// ----------------------------------------------------------------------------
19
20
// This class is MT-safe and its WakeUp() can be called from any thread and
21
// even from a signal handler.
22
23
class wxWakeUpPipe : public wxEventLoopSourceHandler
24
{
25
public:
26
    // Create and initialize the pipe.
27
    //
28
    // It's the callers responsibility to add the read end of this pipe,
29
    // returned by GetReadFd(), to the code blocking on input.
30
    wxWakeUpPipe();
31
32
    // Wake up the blocking operation involving this pipe.
33
    //
34
    // It simply writes to the write end of the pipe, which is non-blocking,
35
    // and doesn't do anything else, so it can be called from any thread and
36
    // also from a signal handler (it also preserves errno for this reason).
37
    void WakeUp();
38
39
    // Return the read end of the pipe.
40
0
    int GetReadFd() { return m_pipe[wxPipe::Read]; }
41
42
43
    // Implement wxEventLoopSourceHandler pure virtual methods
44
    virtual void OnReadWaiting() override;
45
0
    virtual void OnWriteWaiting() override { }
46
0
    virtual void OnExceptionWaiting() override { }
47
48
private:
49
    wxPipe m_pipe;
50
};
51
52
#endif // _WX_UNIX_PRIVATE_WAKEUPPIPE_H_