CommRaT 2.0.0
C++20 Real-Time Messaging Framework
Loading...
Searching...
No Matches
commrat::Thread Class Reference

Thread wrapper with realtime support. More...

#include <commrat/platform/threading.hpp>

Public Member Functions

 Thread ()=default
 Default constructor - no thread running.
 
template<typename Func >
 Thread (const ThreadConfig &config, Func &&func)
 Create and start thread with function.
 
 Thread (const ThreadConfig &config)
 Create thread without starting (call start() later)
 
 ~Thread ()
 Destructor - joins if joinable.
 
 Thread (const Thread &)=delete
 
Threadoperator= (const Thread &)=delete
 
 Thread (Thread &&)=default
 
Threadoperator= (Thread &&)=default
 
template<typename Func >
void start (Func &&func)
 Start thread with function (if not already started)
 
void join ()
 Join thread (wait for completion)
 
void detach ()
 Detach thread.
 
bool joinable () const noexcept
 Check if thread is joinable.
 
std::thread::native_handle_type native_handle ()
 Get native thread handle.
 
std::thread::id get_id () const noexcept
 Get thread ID.
 
const ThreadConfigconfig () const noexcept
 Get thread configuration.
 

Detailed Description

Thread wrapper with realtime support.

Abstraction over std::thread with additional features:

  • Thread priorities
  • CPU affinity
  • Realtime scheduling policies
  • Named threads (for debugging)

Usage: Thread worker(config, []{ do_work(); }); worker.join();

Definition at line 76 of file threading.hpp.

Constructor & Destructor Documentation

◆ Thread() [1/5]

commrat::Thread::Thread ( )
default

Default constructor - no thread running.

◆ Thread() [2/5]

template<typename Func >
commrat::Thread::Thread ( const ThreadConfig config,
Func &&  func 
)
inline

Create and start thread with function.

Parameters
configThread configuration
funcFunction to execute

Definition at line 90 of file threading.hpp.

◆ Thread() [3/5]

commrat::Thread::Thread ( const ThreadConfig config)
inlineexplicit

Create thread without starting (call start() later)

Definition at line 100 of file threading.hpp.

◆ ~Thread()

commrat::Thread::~Thread ( )
inline

Destructor - joins if joinable.

Definition at line 107 of file threading.hpp.

◆ Thread() [4/5]

commrat::Thread::Thread ( const Thread )
delete

◆ Thread() [5/5]

commrat::Thread::Thread ( Thread &&  )
default

Member Function Documentation

◆ config()

const ThreadConfig & commrat::Thread::config ( ) const
inlinenoexcept

Get thread configuration.

Definition at line 174 of file threading.hpp.

◆ detach()

void commrat::Thread::detach ( )
inline

Detach thread.

Definition at line 144 of file threading.hpp.

◆ get_id()

std::thread::id commrat::Thread::get_id ( ) const
inlinenoexcept

Get thread ID.

Definition at line 167 of file threading.hpp.

◆ join()

void commrat::Thread::join ( )
inline

Join thread (wait for completion)

Definition at line 135 of file threading.hpp.

◆ joinable()

bool commrat::Thread::joinable ( ) const
inlinenoexcept

Check if thread is joinable.

Definition at line 153 of file threading.hpp.

◆ native_handle()

std::thread::native_handle_type commrat::Thread::native_handle ( )
inline

Get native thread handle.

Definition at line 160 of file threading.hpp.

◆ operator=() [1/2]

Thread & commrat::Thread::operator= ( const Thread )
delete

◆ operator=() [2/2]

Thread & commrat::Thread::operator= ( Thread &&  )
default

◆ start()

template<typename Func >
void commrat::Thread::start ( Func &&  func)
inline

Start thread with function (if not already started)

Definition at line 123 of file threading.hpp.


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