Libthreadar 1.5.0
|
Class thread_signal provide the same interface as class thread but relies on a signal to wakeup the tread if it was pending on a system call. More...
#include <thread_signal.hpp>
Inherits libthreadar::thread.
Public Member Functions | |
thread_signal () | |
constructor | |
thread_signal (const thread_signal &ref)=delete | |
copy constructor and assignment operator are disabled from libhtreadar::thread | |
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 |
destructor | |
void | set_signal_mask (const sigset_t &mask) |
set signal mask for this object's when the thread_signal will be run More... | |
![]() | |
thread () | |
constructor | |
thread (const thread &ref)=delete | |
copy constructor and assignment operator are disabled | |
thread (thread &&ref) noexcept=default | |
thread & | operator= (const thread &ref)=delete |
thread & | operator= (thread &&ref) noexcept=default |
virtual | ~thread () |
destructor | |
void | set_signal_mask (const sigset_t &mask) |
set signal mask for this object's when the thread will be run More... | |
void | run () |
launch the current object routing in a separated thread | |
bool | is_running () const |
checks whether a separated thread is running the inherited_run() method of this object More... | |
bool | is_running (pthread_t &id) const |
checks whether the object is running in a separated thread More... | |
void | join () const |
the caller will be suspended until the current object's thread ends | |
void | kill () const |
void | cancel () |
the caller send a cancellation request to this object's running thread if any More... | |
Static Public Member Functions | |
static void | change_default_signal (int sig) |
change the signal used to awake threads More... | |
Protected Member Functions | |
virtual void | signaled_inherited_cancel () |
replaces thread::inherited_cancel() More... | |
![]() | |
virtual void | inherited_run ()=0 |
action to be performed in the separated thread More... | |
void | cancellation_checkpoint () const |
available withing the inherited_run() method to eventually trigger thread cancellation More... | |
virtual void | inherited_cancel () |
Class thread_signal provide the same interface as class thread but relies on a signal to wakeup the tread if it was pending on a system call.
this class derives from class libthread::thread and is used the same. However a signal has to be reserved for the whole process and thus for all threads to awake thread in case it would be pending on a system call. In such situation system call return EINTR code and your thread should consider this value as usually and probably retry the system call. Though, this let your code invoke the cancellation_checkpoint() method that will and only this will trigger the end of the thread by throwing an thread::cancel_except exception that should not be catched by the code of inherited_run() method. The signal handle associated to this signal does nothing, so if your code does not call cancellation_checkpoint() it will continue to run transparently (except for system call that return EINTR in that context).
Definition at line 60 of file thread_signal.hpp.
|
static |
change the signal used to awake threads
void libthreadar::thread_signal::set_signal_mask | ( | const sigset_t & | mask | ) |
set signal mask for this object's when the thread_signal will be run
|
inlineprotectedvirtual |
replaces thread::inherited_cancel()
Definition at line 94 of file thread_signal.hpp.