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

Non-owning view over an externally managed std::thread. More...

#include <thread_wrapper.hpp>

Inheritance diagram for threadschedule::ThreadWrapperView:
[legend]
Collaboration diagram for threadschedule::ThreadWrapperView:
[legend]

Public Member Functions

 ThreadWrapperView (std::thread &t)
auto get () noexcept -> std::thread &
auto get () const noexcept -> std::thread const &
Public Member Functions inherited from threadschedule::BaseThreadWrapper< std::thread, detail::NonOwningTag >
void join ()
void detach ()
auto joinable () const noexcept -> bool
auto get_id () const noexcept -> id
auto native_handle () noexcept -> native_handle_type
auto set_name (std::string const &name) -> expected< void, std::error_code >
auto get_name () const -> std::optional< std::string >
auto set_priority (ThreadPriority priority) -> expected< void, std::error_code >
auto set_scheduling_policy (SchedulingPolicy policy, ThreadPriority priority) -> expected< void, std::error_code >
auto set_affinity (ThreadAffinity const &affinity) -> expected< void, std::error_code >
auto get_affinity () const -> std::optional< ThreadAffinity >

Additional Inherited Members

Public Types inherited from threadschedule::BaseThreadWrapper< std::thread, detail::NonOwningTag >
using native_handle_type
using id
Static Public Member Functions inherited from threadschedule::BaseThreadWrapper< std::thread, detail::NonOwningTag >
static auto set_nice_value (int nice_value) -> bool
static auto get_nice_value () -> std::optional< int >

Detailed Description

Non-owning view over an externally managed std::thread.

Provides the full BaseThreadWrapper interface (naming, priority, affinity, etc.) without taking ownership of the thread. The destructor is trivial - it does not join or detach.

Warning
The referenced std::thread must outlive this view. If the thread object is destroyed or moved while a view still references it, all subsequent operations through the view invoke undefined behavior.
Copyability / Movability
Implicitly copyable and movable (pointer semantics). Multiple views may alias the same thread.
Thread Safety
Same caveats as BaseThreadWrapper. Concurrent use of a view and direct use of the underlying thread must be externally synchronized.

Definition at line 644 of file thread_wrapper.hpp.

Constructor & Destructor Documentation

◆ ThreadWrapperView()

threadschedule::ThreadWrapperView::ThreadWrapperView ( std::thread & t)
inline

Definition at line 647 of file thread_wrapper.hpp.

Member Function Documentation

◆ get() [1/2]

auto threadschedule::ThreadWrapperView::get ( ) const -> std::thread const&
inlinenodiscardnoexcept

Definition at line 656 of file thread_wrapper.hpp.

◆ get() [2/2]

auto threadschedule::ThreadWrapperView::get ( ) -> std::thread&
inlinenoexcept

Definition at line 652 of file thread_wrapper.hpp.


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