thread class.
More...
#include <thread.hpp>
|
| | Thread () noexcept=default |
| | default constructor.
|
| |
| template<class Function , class... Args> |
| | Thread (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, 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.
|
| |
| pthread_t | handle () const noexcept |
| | get the handle of the thread of execution. @retunr thread of execution handle.
|
| |
◆ Thread() [1/5]
◆ Thread() [2/5]
template<class Function , class... Args>
| join::Thread::Thread |
( |
Function && | func, |
|
|
Args &&... | args ) |
|
inlineexplicit |
creates a new thread object associated with a thread of execution.
- Parameters
-
| func | callable object to execute in the new thread. |
| args... | arguments to pass to the new function. |
◆ Thread() [3/5]
template<class Function , class... Args>
| join::Thread::Thread |
( |
int | core, |
|
|
int | prio, |
|
|
Function && | func, |
|
|
Args &&... | args ) |
|
inlineexplicit |
creates a new thread object associated with a thread of execution.
- Parameters
-
| 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. |
◆ Thread() [4/5]
| join::Thread::Thread |
( |
const Thread & | other | ) |
|
|
delete |
copy constructor.
- Parameters
-
| other | other object to copy. |
◆ Thread() [5/5]
| Thread::Thread |
( |
Thread && | other | ) |
|
|
noexcept |
move constructor.
- Parameters
-
| other | other object to move. |
◆ ~Thread()
destroys the thread object.
◆ affinity() [1/3]
| int Thread::affinity |
( |
| ) |
const |
|
noexcept |
get current thread affinity.
- Returns
- affinity or -1 if not pinned.
◆ affinity() [2/3]
| int Thread::affinity |
( |
int | core | ) |
|
set thread affinity.
- Parameters
-
| core | thread core affinity (-1 to disable pinning). |
- Returns
- 0 on success, -1 on failure.
◆ affinity() [3/3]
| int Thread::affinity |
( |
pthread_t | handle, |
|
|
int | core ) |
|
static |
set thread affinity.
- Parameters
-
| handle | thread handle. |
| core | thread core affinity (-1 to disable pinning). |
- Returns
- 0 on success, -1 on failure.
◆ cancel()
cancel the running thread if any.
◆ handle()
| pthread_t Thread::handle |
( |
| ) |
const |
|
noexcept |
get the handle of the thread of execution. @retunr thread of execution handle.
◆ join()
block the current thread until the running thread finishes its execution.
◆ joinable()
| bool Thread::joinable |
( |
| ) |
const |
|
noexcept |
check if thread is joinable.
- Returns
- true if joinable.
◆ operator=() [1/2]
copy assignment.
- Parameters
-
| other | other object to copy. |
- Returns
- a reference to the current object.
◆ operator=() [2/2]
move assignment.
- Parameters
-
| other | other object to move. |
- Returns
- a reference to the current object.
◆ priority() [1/3]
| int Thread::priority |
( |
| ) |
const |
|
noexcept |
get current thread priority.
- Returns
- priority.
◆ priority() [2/3]
| int Thread::priority |
( |
int | prio | ) |
|
set thread priority.
- Parameters
-
| prio | thread priority (0 = SCHED_OTHER, 1-99 = SCHED_FIFO). |
- Returns
- 0 on success, -1 on failure.
◆ priority() [3/3]
| int Thread::priority |
( |
pthread_t | handle, |
|
|
int | prio ) |
|
static |
set thread priority.
- Parameters
-
| handle | thread handle. |
| prio | thread priority (0 = SCHED_OTHER, 1-99 = SCHED_FIFO). |
- Returns
- 0 on success, -1 on failure.
◆ running()
| bool Thread::running |
( |
| ) |
const |
|
noexcept |
check if the thread is running.
- Returns
- true if running, false otherwise.
◆ swap()
| void Thread::swap |
( |
Thread & | other | ) |
|
|
noexcept |
swap underlying handles of two thread objects.
- Parameters
-
| other | the thread to swap with. |
◆ tryJoin()
performs a nonblocking join on the running thread.
- Returns
- true if thread was joined, false if running thread didn't finished its execution.
The documentation for this class was generated from the following files: