|
join 1.0
lightweight network framework library
|
thread class. More...
#include <thread.hpp>
Public Member Functions | |
| Thread () noexcept=default | |
| default constructor. | |
| template<class Function , class... Args> requires (!std::is_arithmetic_v<std::decay_t<Function>>) | |
| Thread (Function &&func, Args &&... args) | |
| creates a new thread object associated with a thread of execution. | |
| template<class Function , class... Args> requires (!std::is_arithmetic_v<std::decay_t<Function>>) | |
| Thread (int core, int prio, Function &&func, Args &&... args) | |
| creates a new thread object associated with a thread of execution. | |
| template<class Function , class... Args> | |
| Thread (int core, int prio, size_t stackSize, bool prefault, Function &&func, Args &&... args) | |
| creates a new thread object associated with a thread of execution. | |
| Thread (const Thread &other)=delete | |
| copy constructor. | |
| Thread & | operator= (const Thread &other)=delete |
| copy assignment. | |
| Thread (Thread &&other) noexcept | |
| move constructor. | |
| Thread & | operator= (Thread &&other) noexcept |
| move assignment. | |
| ~Thread () | |
| destroys the thread object. | |
| int | affinity (int core) |
| set thread affinity. | |
| int | affinity () const noexcept |
| get current thread affinity. | |
| int | priority (int prio) |
| set thread priority. | |
| int | priority () const noexcept |
| get current thread priority. | |
| bool | joinable () const noexcept |
| check if thread is joinable. | |
| bool | running () const noexcept |
| check if the thread is running. | |
| void | join () noexcept |
| block the current thread until the running thread finishes its execution. | |
| bool | tryJoin () noexcept |
| performs a nonblocking join on the running thread. | |
| void | cancel () noexcept |
| cancel the running thread if any. | |
| void | swap (Thread &other) noexcept |
| swap underlying handles of two thread objects. | |
| pid_t | id () const noexcept |
| get thread id. | |
| pthread_t | handle () const noexcept |
| get the handle of the thread of execution. | |
Static Public Member Functions | |
| static int | affinity (pthread_t handle, int core) |
| set thread affinity. | |
| static int | priority (pthread_t handle, int prio) |
| set thread priority. | |
| static pid_t | currentId () noexcept |
| get calling thread id. | |
Static Public Attributes | |
| static constexpr pid_t | invalidId = Invoker::_invalidId |
| invalid thread id. | |
thread class.
|
defaultnoexcept |
default constructor.
|
inlineexplicit |
creates a new thread object associated with a thread of execution.
| func | callable object to execute in the new thread. |
| args... | arguments to pass to the new function. |
| std::system_error | if the thread of execution cannot be created. |
|
inlineexplicit |
creates a new thread object associated with a thread of execution.
| core | thread core affinity (-1 no pinning). |
| prio | thread priority (0 = SCHED_OTHER, 1-99 = SCHED_FIFO). |
| func | callable object to execute in the new thread. |
| args... | arguments to pass to the new function. |
| std::system_error | if the thread of execution cannot be created. |
|
inlineexplicit |
creates a new thread object associated with a thread of execution.
| core | thread core affinity (-1 no pinning). |
| prio | thread priority (0 = SCHED_OTHER, 1-99 = SCHED_FIFO). |
| stackSize | thread stack size (0 = default). |
| prefault | prefault thread stack. |
| func | callable object to execute in the new thread. |
| args... | arguments to pass to the new function. |
| std::system_error | if the thread of execution cannot be created. |
|
delete |
copy constructor.
| other | other object to copy. |
|
noexcept |
move constructor.
| other | other object to move. |
| Thread::~Thread | ( | ) |
destroys the thread object.
|
noexcept |
get current thread affinity.
| int Thread::affinity | ( | int | core | ) |
set thread affinity.
| core | thread core affinity (-1 to disable pinning). |
|
static |
set thread affinity.
| handle | thread handle. |
| core | thread core affinity (-1 to disable pinning). |
|
noexcept |
cancel the running thread if any.
|
inlinestaticnoexcept |
get calling thread id.
|
noexcept |
get the handle of the thread of execution.
|
noexcept |
get thread id.
|
noexcept |
block the current thread until the running thread finishes its execution.
|
noexcept |
check if thread is joinable.
copy assignment.
| other | other object to copy. |
move assignment.
| other | other object to move. |
|
noexcept |
get current thread priority.
| int Thread::priority | ( | int | prio | ) |
set thread priority.
| prio | thread priority (0 = SCHED_OTHER, 1-99 = SCHED_FIFO). |
|
static |
set thread priority.
| handle | thread handle. |
| prio | thread priority (0 = SCHED_OTHER, 1-99 = SCHED_FIFO). |
|
noexcept |
check if the thread is running.
|
noexcept |
swap underlying handles of two thread objects.
| other | the thread to swap with. |
|
noexcept |
performs a nonblocking join on the running thread.
|
staticconstexpr |
invalid thread id.