Libthreadar 1.5.0
Loading...
Searching...
No Matches
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-2024 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
78
81 // will ignore it
82 void set_signal_mask(const sigset_t & mask);
83
85
87 static void change_default_signal(int sig);
88
89 protected:
90
92
94 virtual void signaled_inherited_cancel() {};
95
96 private:
97
104 virtual void inherited_cancel() override;
105
106 static mutex verrou;
107 static bool initialized;
108 static int awaking_signal;
109
110 static void set_signal_handler();
111 static void handler(int sig);
112 };
113
114} // end of namespace
115
116#endif
Wrapper around the Posix pthread_mutex_t C objects.
Definition mutex.hpp:57
Class thread_signal provide the same interface as class thread but relies on a signal to wakeup the t...
static void change_default_signal(int sig)
change the signal used to awake threads
void set_signal_mask(const sigset_t &mask)
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()
Class thread is a pure virtual class, that implements thread creation and operations.
Definition thread.hpp:99
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