The thread wrapper.
More...
#include <thread.h>
|
bool | run () noexcept |
| Creates a new thread.
|
|
bool | run (create_flags opts, std::size_t stack={}) noexcept |
| Creates a new thread.
|
|
bool | join () noexcept |
| Joins with a terminated thread.
|
|
virtual int | init () |
| Initializes the handle.
|
|
loop & | parent () const noexcept |
| Gets the loop from which the resource was originated.
|
|
const uv_thread_t * | raw () const noexcept |
| Gets the underlying raw data structure.
|
|
uv_thread_t * | raw () noexcept |
| Gets the underlying raw data structure.
|
|
|
static type | self () noexcept |
| Obtains the identifier of the calling thread.
|
|
static int | getcpu () noexcept |
| Gets the CPU number on which the calling thread is running.
|
|
static bool | equal (const thread &tl, const thread &tr) noexcept |
| Compares thread by means of their identifiers.
|
|
The thread wrapper.
To create a thread
through a loop
, arguments follow:
- A callback invoked to initialize thread execution. The type must be such that it can be assigned to an
std::function<void(std::shared_ptr<void>)>
.
- An optional payload the type of which is
std::shared_ptr<void>
.
Definition at line 45 of file thread.h.
◆ equal()
static bool uvw::thread::equal |
( |
const thread & |
tl, |
|
|
const thread & |
tr |
|
) |
| |
|
staticnoexcept |
Compares thread by means of their identifiers.
- Parameters
-
tl | A valid instance of a thread. |
tr | A valid instance of a thread. |
- Returns
- True if the two threads are the same thread, false otherwise.
◆ getcpu()
static int uvw::thread::getcpu |
( |
| ) |
|
|
staticnoexcept |
Gets the CPU number on which the calling thread is running.
- Returns
- The CPU number on which the calling thread is running.
◆ join()
bool uvw::thread::join |
( |
| ) |
|
|
noexcept |
Joins with a terminated thread.
- Returns
- True in case of success, false otherwise.
◆ run() [1/2]
bool uvw::thread::run |
( |
| ) |
|
|
noexcept |
Creates a new thread.
- Returns
- True in case of success, false otherwise.
◆ run() [2/2]
bool uvw::thread::run |
( |
create_flags |
opts, |
|
|
std::size_t |
stack = {} |
|
) |
| |
|
noexcept |
Creates a new thread.
Available flags are:
thread::create_flags::THREAD_NO_FLAGS
: no flags set.
thread::create_flags::THREAD_HAS_STACK_SIZE
: if set, stack
specifies a stack size for the new thread. 0 indicates that the default value should be used (it behaves as if the flag was not set). Other values will be rounded up to the nearest page boundary.
- Returns
- True in case of success, false otherwise.
◆ self()
static type uvw::thread::self |
( |
| ) |
|
|
staticnoexcept |
Obtains the identifier of the calling thread.
- Returns
- The identifier of the calling thread.
The documentation for this class was generated from the following file: