|
Libthreadar 1.6.0
|
Class thread_signal provides the same interface as class thread but in addition relies on a signal to awake 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 | |
| virtual void | set_signal_mask (const sigset_t &mask) override |
| set signal mask for this object's when the thread_signal will be run | |
| Public Member Functions inherited from libthreadar::thread | |
| 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 | reset_stack_size () |
| reset the stack size to the system default value | |
| void | set_stack_size (unsigned int val) |
| set the stack size to non default value | |
| unsigned int | get_stack_size () const |
| get the current stack size value | |
| 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 | |
| bool | is_running (pthread_t &id) const |
| checks whether the object is running in a separated thread | |
| 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 | |
Static Public Member Functions | |
| static void | change_default_signal (int sig) |
| change the signal used to awake threads | |
Protected Member Functions | |
| virtual void | signaled_inherited_cancel () |
| replaces thread::inherited_cancel() and should be used instead of it | |
| Protected Member Functions inherited from libthreadar::thread | |
| virtual void | inherited_run ()=0 |
| action to be performed in the separated thread (implementation is expected in inherited classes) | |
| void | cancellation_checkpoint () const |
| available withing the inherited_run() method to eventually trigger thread cancellation | |
Class thread_signal provides the same interface as class thread but in addition relies on a signal to awake the tread if it was pending on a system call.
This class derives from class libthreadar::thread and is used the same. However a signal has to be reserved for the whole process for any thread to be awaken in case it would be pending on a system call. In such situation a system call returns EINTR code and your thread implementation should consider this value as usually and probably retry the system call. Though, before retrying, this let your code invoke the cancellation_checkpoint() method to check whether an thread cancellation was requested, which method will in that case throw a thread::cancel_except exception that should not be catched by the code of inherited_run() method. The signal handle associated to this signal is implemented in this class but does nothing. So if your code does not call cancellation_checkpoint() it will continue to run normally, except for the point when the thread was pending on a system call which will in that case return EINTR.
Definition at line 60 of file thread_signal.hpp.
|
static |
change the signal used to awake threads
|
overridevirtual |
set signal mask for this object's when the thread_signal will be run
Reimplemented from libthreadar::thread.
|
inlineprotectedvirtual |
replaces thread::inherited_cancel() and should be used instead of it
Definition at line 105 of file thread_signal.hpp.