ThreadSchedule 1.0.0
Modern C++ thread management library
Loading...
Searching...
No Matches
threadschedule::PThreadWrapper Class Reference

RAII pthread wrapper with modern C++ interface. More...

#include <pthread_wrapper.hpp>

Inheritance diagram for threadschedule::PThreadWrapper:
[legend]

Public Types

using native_handle_type = pthread_t
using id = pthread_t

Public Member Functions

template<typename F, typename... Args>
 PThreadWrapper (F &&func, Args &&... args)
 PThreadWrapper (PThreadWrapper const &)=delete
auto operator= (PThreadWrapper const &) -> PThreadWrapper &=delete
 PThreadWrapper (PThreadWrapper &&other) noexcept
auto operator= (PThreadWrapper &&other) noexcept -> PThreadWrapper &
void join ()
void detach ()
auto joinable () const -> bool
auto get_id () const -> id
auto native_handle () const -> native_handle_type
auto set_name (std::string const &name) const -> expected< void, std::error_code >
auto get_name () const -> std::optional< std::string >
auto set_priority (ThreadPriority priority) const -> expected< void, std::error_code >
auto set_scheduling_policy (SchedulingPolicy policy, ThreadPriority priority) const -> expected< void, std::error_code >
auto set_affinity (ThreadAffinity const &affinity) const -> expected< void, std::error_code >
auto get_affinity () const -> std::optional< ThreadAffinity >
auto cancel () const -> expected< void, std::error_code >

Static Public Member Functions

static auto set_cancel_state (bool enabled) -> expected< void, std::error_code >
static auto set_cancel_type (bool asynchronous) -> expected< void, std::error_code >
template<typename F, typename... Args>
static auto create_with_config (std::string const &name, SchedulingPolicy policy, ThreadPriority priority, F &&f, Args &&... args) -> PThreadWrapper
template<typename F, typename... Args>
static auto create_with_attributes (pthread_attr_t const &attr, F &&func, Args &&... args) -> PThreadWrapper

Detailed Description

RAII pthread wrapper with modern C++ interface.

Definition at line 27 of file pthread_wrapper.hpp.

Member Typedef Documentation

◆ id

using threadschedule::PThreadWrapper::id = pthread_t

Definition at line 31 of file pthread_wrapper.hpp.

◆ native_handle_type

using threadschedule::PThreadWrapper::native_handle_type = pthread_t

Definition at line 30 of file pthread_wrapper.hpp.

Constructor & Destructor Documentation

◆ PThreadWrapper() [1/3]

threadschedule::PThreadWrapper::PThreadWrapper ( )
inline

Definition at line 33 of file pthread_wrapper.hpp.

◆ PThreadWrapper() [2/3]

template<typename F, typename... Args>
threadschedule::PThreadWrapper::PThreadWrapper ( F && func,
Args &&... args )
inlineexplicit

Definition at line 38 of file pthread_wrapper.hpp.

◆ PThreadWrapper() [3/3]

threadschedule::PThreadWrapper::PThreadWrapper ( PThreadWrapper && other)
inlinenoexcept

Definition at line 58 of file pthread_wrapper.hpp.

◆ ~PThreadWrapper()

threadschedule::PThreadWrapper::~PThreadWrapper ( )
inline

Definition at line 80 of file pthread_wrapper.hpp.

Member Function Documentation

◆ cancel()

auto threadschedule::PThreadWrapper::cancel ( ) const -> expected<void, std::error_code>
inlinenodiscard

Definition at line 197 of file pthread_wrapper.hpp.

◆ create_with_attributes()

template<typename F, typename... Args>
auto threadschedule::PThreadWrapper::create_with_attributes ( pthread_attr_t const & attr,
F && func,
Args &&... args ) -> PThreadWrapper
inlinestatic

Definition at line 235 of file pthread_wrapper.hpp.

◆ create_with_config()

template<typename F, typename... Args>
auto threadschedule::PThreadWrapper::create_with_config ( std::string const & name,
SchedulingPolicy policy,
ThreadPriority priority,
F && f,
Args &&... args ) -> PThreadWrapper
inlinestatic

Definition at line 224 of file pthread_wrapper.hpp.

◆ detach()

void threadschedule::PThreadWrapper::detach ( )
inline

Definition at line 102 of file pthread_wrapper.hpp.

◆ get_affinity()

auto threadschedule::PThreadWrapper::get_affinity ( ) const -> std::optional<ThreadAffinity>
inlinenodiscard

Definition at line 186 of file pthread_wrapper.hpp.

◆ get_id()

auto threadschedule::PThreadWrapper::get_id ( ) const -> id
inlinenodiscard

Definition at line 119 of file pthread_wrapper.hpp.

◆ get_name()

auto threadschedule::PThreadWrapper::get_name ( ) const -> std::optional<std::string>
inlinenodiscard

Definition at line 138 of file pthread_wrapper.hpp.

◆ join()

void threadschedule::PThreadWrapper::join ( )
inline

Definition at line 89 of file pthread_wrapper.hpp.

◆ joinable()

auto threadschedule::PThreadWrapper::joinable ( ) const -> bool
inlinenodiscard

Definition at line 114 of file pthread_wrapper.hpp.

◆ native_handle()

auto threadschedule::PThreadWrapper::native_handle ( ) const -> native_handle_type
inlinenodiscard

Definition at line 123 of file pthread_wrapper.hpp.

◆ operator=()

auto threadschedule::PThreadWrapper::operator= ( PThreadWrapper && other) -> PThreadWrapper&
inlinenoexcept

Definition at line 64 of file pthread_wrapper.hpp.

◆ set_affinity()

auto threadschedule::PThreadWrapper::set_affinity ( ThreadAffinity const & affinity) const -> expected<void, std::error_code>
inlinenodiscard

Definition at line 179 of file pthread_wrapper.hpp.

◆ set_cancel_state()

auto threadschedule::PThreadWrapper::set_cancel_state ( bool enabled) -> expected<void, std::error_code>
inlinestatic

Definition at line 204 of file pthread_wrapper.hpp.

◆ set_cancel_type()

auto threadschedule::PThreadWrapper::set_cancel_type ( bool asynchronous) -> expected<void, std::error_code>
inlinestatic

Definition at line 213 of file pthread_wrapper.hpp.

◆ set_name()

auto threadschedule::PThreadWrapper::set_name ( std::string const & name) const -> expected<void, std::error_code>
inlinenodiscard

Definition at line 129 of file pthread_wrapper.hpp.

◆ set_priority()

auto threadschedule::PThreadWrapper::set_priority ( ThreadPriority priority) const -> expected<void, std::error_code>
inlinenodiscard

Definition at line 148 of file pthread_wrapper.hpp.

◆ set_scheduling_policy()

auto threadschedule::PThreadWrapper::set_scheduling_policy ( SchedulingPolicy policy,
ThreadPriority priority ) const -> expected<void, std::error_code>
inlinenodiscard

Definition at line 163 of file pthread_wrapper.hpp.


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