Libthreadar 1.6.0
thread_signal.hpp
Go to the documentation of this file.
1/*********************************************************************/
2// libthreadar - is a library providing several C++ classes to work with threads
3// Copyright (C) 2014-2025 Denis Corbin
4//
5// This file is part of libthreadar
6//
7// libthreadar is free software: you can redistribute it and/or modify
8// it under the terms of the GNU Lesser General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// libhtreadar is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU Lesser General Public License for more details.
16//
17// You should have received a copy of the GNU Lesser General Public License
18// along with libthreadar. If not, see <http://www.gnu.org/licenses/>
19//
20//----
21// to contact the author: dar.linux@free.fr
22/*********************************************************************/
23
24#ifndef LIBTHREADAR_THREAD_SIGNAL_HPP
25#define LIBTHREADAR_THREAD_SIGNAL_HPP
26
30
31#include "config.h"
32
33 // C system headers
34
35 // C++ standard headers
36
37
38 // libthreadar headers
39#include "thread.hpp"
40
41namespace libthreadar
42{
43
45
59
60 class thread_signal: public thread
61 {
62 public:
65
67 thread_signal(const thread_signal & ref) = delete;
68 thread_signal(thread_signal && ref) noexcept = default;
69 thread_signal & operator = (const thread_signal & ref) = delete;
70 thread_signal & operator = (thread_signal && ref) noexcept = default;
71
73 virtual ~thread_signal() = default; // no thread to cancel nor data to cleanup here
74
76
82 virtual void set_signal_mask(const sigset_t & mask) override;
83
85
87
94 static void change_default_signal(int sig);
95
96 protected:
97
99
105 virtual void signaled_inherited_cancel() {};
106
107 private:
108
115 virtual void inherited_cancel() override;
116
118 void send_signal();
119
120 static mutex verrou;
121 static bool initialized;
122 static int awaking_signal;
123
124 static void set_signal_handler();
125 static void handler(int sig);
126 };
127
128} // end of namespace
129
130#endif
Wrapper around the Posix pthread_mutex_t C objects.
Definition: mutex.hpp:57
Class thread_signal provides the same interface as class thread but in addition relies on a signal to...
static void change_default_signal(int sig)
change the signal used to awake threads
virtual void set_signal_mask(const sigset_t &mask) override
set signal mask for this object's when the thread_signal will be run
virtual ~thread_signal()=default
destructor
thread_signal(const thread_signal &ref)=delete
copy constructor and assignment operator are disabled from libhtreadar::thread
virtual void signaled_inherited_cancel()
replaces thread::inherited_cancel() and should be used instead of it
Class thread is a pure virtual class, that implements thread creation and operations.
Definition: thread.hpp:102
This is the only namespace used in libthreadar and all symbols provided by libthreadar are member of ...
Definition: barrier.hpp:46
holds the definition of the thread class