Loading...
Searching...
No Matches
thread_signal.hpp
Go to the documentation of this file.
/*********************************************************************/
// libthreadar - is a library providing several C++ classes to work with threads
// Copyright (C) 2014-2025 Denis Corbin
//
// This file is part of libthreadar
//
// libthreadar is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// libhtreadar is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with libthreadar. If not, see <http://www.gnu.org/licenses/>
//
//----
// to contact the author: dar.linux@free.fr
/*********************************************************************/
#ifndef LIBTHREADAR_THREAD_SIGNAL_HPP
#define LIBTHREADAR_THREAD_SIGNAL_HPP
#include "config.h"
// C system headers
// C++ standard headers
// libthreadar headers
#include "thread.hpp"
namespace libthreadar
{
class thread_signal: public thread
{
public:
thread_signal();
thread_signal(const thread_signal & ref) = delete;
thread_signal(thread_signal && ref) noexcept = default;
thread_signal & operator = (const thread_signal & ref) = delete;
thread_signal & operator = (thread_signal && ref) noexcept = default;
virtual ~thread_signal() = default; // no thread to cancel nor data to cleanup here
virtual void set_signal_mask(const sigset_t & mask) override;
static void change_default_signal(int sig);
protected:
virtual void signaled_inherited_cancel() {};
private:
virtual void inherited_cancel() override;
void send_signal();
static mutex verrou;
static bool initialized;
static int awaking_signal;
static void set_signal_handler();
static void handler(int sig);
};
} // end of namespace
#endif
libthreadar::mutex
Wrapper around the Posix pthread_mutex_t C objects.
Definition mutex.hpp:57
libthreadar::thread_signal
Class thread_signal provides the same interface as class thread but in addition relies on a signal to...
Definition thread_signal.hpp:61
libthreadar::thread_signal::change_default_signal
static void change_default_signal(int sig)
change the signal used to awake threads
libthreadar::thread_signal::thread_signal
thread_signal()
constructor
libthreadar::thread_signal::set_signal_mask
virtual void set_signal_mask(const sigset_t &mask) override
set signal mask for this object's when the thread_signal will be run
libthreadar::thread_signal::~thread_signal
virtual ~thread_signal()=default
destructor
libthreadar::thread_signal::thread_signal
thread_signal(const thread_signal &ref)=delete
copy constructor and assignment operator are disabled from libhtreadar::thread
libthreadar::thread_signal::signaled_inherited_cancel
virtual void signaled_inherited_cancel()
replaces thread::inherited_cancel() and should be used instead of it
Definition thread_signal.hpp:105
libthreadar::thread
Class thread is a pure virtual class, that implements thread creation and operations.
Definition thread.hpp:102
libthreadar
This is the only namespace used in libthreadar and all symbols provided by libthreadar are member of ...
Definition barrier.hpp:46
thread.hpp
holds the definition of the thread class