dius 0.1.0
Loading...
Searching...
No Matches
dius::Thread Class Reference

Class representing a single thread of execution. More...

#include <generic/dius/thread.h>

Public Types

using Id = di::ThreadId
 

Public Member Functions

 Thread ()=default
 
 Thread (Thread const &)=delete
 
 Thread (Thread &&other)
 
 ~Thread ()
 
auto operator= (Thread const &) -> Thread &=delete
 
auto operator= (Thread &&other) -> Thread &
 
auto joinable () const -> bool
 
auto get_id () const -> Id
 
auto join () -> di::Result< void >
 Wait for the spawned thread's execution to terminate.
 

Static Public Member Functions

template<di::concepts::MovableValue F, di::concepts::MovableValue... Args>
requires (di::concepts::InvocableTo<F, void, Args...>)
static auto create (F &&function, Args &&... args) -> di::Result< Thread >
 

Friends

void tag_invoke (di::Tag< di::swap >, Thread &a, Thread &b)
 

Detailed Description

Class representing a single thread of execution.

This class is modeled after the C++ standard library std::thread.

Warning
All Thread objects must be joined before destruction, or the program will terminate.

Member Typedef Documentation

◆ Id

using dius::Thread::Id = di::ThreadId

Constructor & Destructor Documentation

◆ Thread() [1/3]

dius::Thread::Thread ( )
default

◆ Thread() [2/3]

dius::Thread::Thread ( Thread const & )
delete

◆ Thread() [3/3]

dius::Thread::Thread ( Thread && other)
inline

◆ ~Thread()

dius::Thread::~Thread ( )
inline

Member Function Documentation

◆ create()

template<di::concepts::MovableValue F, di::concepts::MovableValue... Args>
requires (di::concepts::InvocableTo<F, void, Args...>)
static auto dius::Thread::create ( F && function,
Args &&... args ) -> di::Result<Thread>
inlinestatic

◆ get_id()

auto dius::Thread::get_id ( ) const -> Id
inlinenodiscard

◆ join()

auto dius::Thread::join ( ) -> di::Result<void>
inline

Wait for the spawned thread's execution to terminate.

Warning
It is undefined behavior to call this method concurrently from different threads.
Returns
Returns an error if the operation failed.

◆ joinable()

auto dius::Thread::joinable ( ) const -> bool
inlinenodiscard

◆ operator=() [1/2]

auto dius::Thread::operator= ( Thread && other) -> Thread&
inline

◆ operator=() [2/2]

auto dius::Thread::operator= ( Thread const & ) -> Thread &=delete
delete

Friends And Related Symbol Documentation

◆ tag_invoke

void tag_invoke ( di::Tag< di::swap > ,
Thread & a,
Thread & b )
friend

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