cpp-pthread
(v1.7.3)
Simple C++ wrapper to pthread functions.
|
#include <thread.hpp>
Public Member Functions | |
thread () | |
thread (const runnable &runner, const std::size_t stack_size=0) | |
thread (thread &&other) | |
thread (const thread &)=delete | |
virtual | ~thread () |
void | join () |
bool | joinable () const |
int | cancel () |
thread_status | status () |
thread & | operator= (const thread &)=delete |
thread & | operator= (thread &&other) |
Handles POSIX (Portable Operating System Interface) threads.
class reader_thread: public runnable {
public:
void run() {...}
};
reader_thread rt;
thread t{rt};
t.join();
Definition at line 91 of file thread.hpp.
pthread::thread::thread | ( | ) |
create a new thread status is no_a_thread
Definition at line 76 of file thread.cpp.
pthread::thread::thread | ( | const runnable & | runner, |
const std::size_t | stack_size = 0 |
||
) |
create a new thread
The new thread is made runnable, and will start executing the run routine, with.
runner | a class that implements the runnable interface. |
stack_size | thread stack size in bytes (default is 0 and means use default stack size) |
Definition at line 81 of file thread.cpp.
pthread::thread::thread | ( | thread && | other | ) |
Move contructor.
once moved this not a thread anymore. Status is thread_status::not_a_thread
other | thread that will be moved, on completion other is no longer a thread. |
Definition at line 110 of file thread.cpp.
|
delete |
Copy constructor is flagged deleted because it makes no sense to copy a thread.
|
virtual |
cleanup thread ressources.
Definition at line 115 of file thread.cpp.
int pthread::thread::cancel | ( | ) |
The cancel method requests the cancellation of the thread. The action depends on the cancelability of the target thread:
The cancellation of a thread terminates it safely, using the same termination procedure as the pthread_exit subroutine.
Definition at line 59 of file thread.cpp.
void pthread::thread::join | ( | ) |
The join method blocks the calling thread until the thread terminates. The target thread's termination status is returned in the status parameter.
If the target thread is already terminated, the method returns immediately.
This method does not itself cause a thread to be terminated.
pthread_exception | if this is not a thread or if thread_id == this_thread::get_id(). |
Definition at line 26 of file thread.cpp.
|
inline |
Definition at line 139 of file thread.hpp.
copy operator is flagged deleted, copying doesn't make sense
move a thread to another thread.
other | thread to move, on completion it is not a thread anymore (thread_status::not_a_thread). |
Definition at line 120 of file thread.cpp.
|
inline |
Definition at line 156 of file thread.hpp.