uvw 3.1.0
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | List of all members
uvw::thread Class Referencefinal

The thread wrapper. More...

#include <thread.h>

Inheritance diagram for uvw::thread:
Inheritance graph
[legend]
Collaboration diagram for uvw::thread:
Collaboration graph
[legend]

Public Member Functions

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.
 
- Public Member Functions inherited from uvw::uv_type< uv_thread_t >
virtual int init ()
 Initializes the handle.
 
loopparent () 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 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.
 

Detailed Description

The thread wrapper.

To create a thread through a loop, arguments follow:

Definition at line 45 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.

◆ 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: