uvw 2.12.1
Loading...
Searching...
No Matches
uvw::Thread Class Referencefinal

The Thread wrapper. More...

#include <thread.h>

Inheritance diagram for uvw::Thread:
Collaboration diagram for uvw::Thread:

Public Member Functions

bool run () noexcept
 Creates a new thread.
 
bool run (Flags< Options > opts, std::size_t stack={}) noexcept
 Creates a new thread.
 
bool join () noexcept
 Joins with a terminated thread.
 
- Public Member Functions inherited from uvw::UnderlyingType< Thread, uv_thread_t >
Looploop () 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 Public Member Functions

static Type self () noexcept
 Obtains the identifier of the calling thread.
 
static bool equal (const Thread &tl, const Thread &tr) noexcept
 Compares thread by means of their identifiers.
 
- Static Public Member Functions inherited from uvw::UnderlyingType< Thread, uv_thread_t >
static std::shared_ptr< Threadcreate (Args &&...args)
 Creates a new resource of the given type.
 

Detailed Description

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 43 of file thread.h.

Member Function Documentation

◆ equal()

static bool uvw::Thread::equal ( const Thread & tl,
const Thread & tr )
staticnoexcept

Compares thread by means of their identifiers.

Parameters
tlA valid instance of a thread.
trA valid instance of a thread.
Returns
True if the two threads are the same thread, false otherwise.

◆ 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 ( Flags< Options > opts,
std::size_t stack = {} )
noexcept

Creates a new thread.

Available flags are:

  • Thread::Options::THREAD_NO_FLAGS: no flags set.
  • Thread::Options::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: