tenno 0.1.0
Loading...
Searching...
No Matches
tenno::jthread Class Reference

The jthread class is a wrapper around std::thread that automatically rejoins the thread on destruction. More...

#include <thread.hpp>

Public Types

using native_handle_type = std::thread::native_handle_type
 The type of the implementation defined thread handle.
 

Public Member Functions

 jthread () noexcept=default
 
 jthread (const jthread &)=delete
 
 jthread (jthread &&other) noexcept
 Construct a new jthread object by moving the other object.
 
template<class F , class... Args>
 jthread (F &&f, Args &&...args)
 Construct a new jthread object with the given function and arguments.
 
 ~jthread ()
 
bool joinable () const noexcept
 
std::thread::id get_id () const noexcept
 
native_handle_type native_handle ()
 Get the native handle of the thread.
 
void join ()
 
void detach ()
 
void swap (tenno::jthread &other) noexcept
 

Static Public Member Functions

static unsigned int hardware_concurrency () noexcept
 Get the number of concurrent threads supported by the implementation.
 

Data Fields

std::thread::id id
 

Detailed Description

The jthread class is a wrapper around std::thread that automatically rejoins the thread on destruction.

Definition at line 17 of file thread.hpp.

Member Typedef Documentation

◆ native_handle_type

using tenno::jthread::native_handle_type = std::thread::native_handle_type

The type of the implementation defined thread handle.

Definition at line 23 of file thread.hpp.

Constructor & Destructor Documentation

◆ jthread() [1/4]

tenno::jthread::jthread ( )
defaultnoexcept

◆ jthread() [2/4]

tenno::jthread::jthread ( const jthread & )
delete

◆ jthread() [3/4]

tenno::jthread::jthread ( jthread && other)
inlinenoexcept

Construct a new jthread object by moving the other object.

Parameters
otherThe other jthread object to move

Definition at line 35 of file thread.hpp.

◆ jthread() [4/4]

template<class F , class... Args>
tenno::jthread::jthread ( F && f,
Args &&... args )
inlineexplicit

Construct a new jthread object with the given function and arguments.

Template Parameters
FThe type of the function to execute
ArgsThe type of the arguments to pass to the function
Parameters
fThe function to execute
argsThe arguments to pass to the function

Definition at line 49 of file thread.hpp.

◆ ~jthread()

tenno::jthread::~jthread ( )
inline

Definition at line 55 of file thread.hpp.

Member Function Documentation

◆ detach()

void tenno::jthread::detach ( )
inline

Definition at line 100 of file thread.hpp.

◆ get_id()

std::thread::id tenno::jthread::get_id ( ) const
inlinenoexcept

Definition at line 68 of file thread.hpp.

◆ hardware_concurrency()

static unsigned int tenno::jthread::hardware_concurrency ( )
inlinestaticnoexcept

Get the number of concurrent threads supported by the implementation.

Returns
unsigned int The number of concurrent threads supported by the implementation

Definition at line 90 of file thread.hpp.

◆ join()

void tenno::jthread::join ( )
inline

Definition at line 95 of file thread.hpp.

◆ joinable()

bool tenno::jthread::joinable ( ) const
inlinenoexcept

Definition at line 63 of file thread.hpp.

◆ native_handle()

native_handle_type tenno::jthread::native_handle ( )
inline

Get the native handle of the thread.

Returns
native_handle_type The native handle of the thread

Definition at line 78 of file thread.hpp.

◆ swap()

void tenno::jthread::swap ( tenno::jthread & other)
inlinenoexcept

Definition at line 105 of file thread.hpp.

Field Documentation

◆ id

std::thread::id tenno::jthread::id

Definition at line 25 of file thread.hpp.


The documentation for this class was generated from the following file: