ThreadSchedule 3.0.0
Modern C++ thread management library
Loading...
Searching...
No Matches
threadschedule::detail::thread_view_backend Class Reference

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

#include <thread_backend.hpp>

Inheritance diagram for threadschedule::detail::thread_view_backend:
[legend]
Collaboration diagram for threadschedule::detail::thread_view_backend:
[legend]

Public Member Functions

 thread_view_backend (std::thread &t)
 
 thread_view_backend (std::thread &t, native_thread_id tid)
 
auto get () noexcept -> std::thread &
 
auto get () const noexcept -> std::thread const &
 
- Public Member Functions inherited from threadschedule::detail::basic_thread_backend< std::thread, detail::non_owning_tag >
 basic_thread_backend ()=default
 
 basic_thread_backend (std::thread &t)
 
 basic_thread_backend (std::thread &t, native_thread_id tid)
 
virtual ~basic_thread_backend ()=default
 
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 -> expected< std::string, std::error_code >
 
auto set_priority (native_thread_priority priority) -> expected< void, std::error_code >
 
auto set_scheduling_policy (native_scheduling_policy policy, native_thread_priority priority) -> expected< void, std::error_code >
 
auto configure (native_scheduling_config const &config) -> expected< void, std::error_code >
 
auto configure (native_thread_config const &config) -> expected< void, std::error_code >
 
auto set_nice_value (int nice_value) -> expected< void, std::error_code >
 
auto get_nice_value () const -> expected< int, std::error_code >
 
auto set_affinity (native_thread_affinity const &affinity) -> expected< void, std::error_code >
 
auto get_affinity () const -> expected< native_thread_affinity, std::error_code >
 
auto native_id () const noexcept -> native_thread_id
 

Additional Inherited Members

- Public Types inherited from threadschedule::detail::basic_thread_backend< std::thread, detail::non_owning_tag >
using native_handle_type = typename ThreadType::native_handle_type
 
using id = typename ThreadType::id
 
- Protected Member Functions inherited from threadschedule::detail::basic_thread_backend< std::thread, detail::non_owning_tag >
void set_native_id (native_thread_id tid) noexcept
 
- Static Protected Member Functions inherited from threadschedule::detail::basic_thread_backend< std::thread, detail::non_owning_tag >
static auto no_such_thread () -> unexpected< std::error_code >
 
- Protected Attributes inherited from threadschedule::detail::basic_thread_backend< std::thread, detail::non_owning_tag >
native_thread_id native_id_
 

Detailed Description

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

Provides the full basic_thread_backend 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 basic_thread_backend. Concurrent use of a view and direct use of the underlying thread must be externally synchronized.

Definition at line 597 of file thread_backend.hpp.

Constructor & Destructor Documentation

◆ thread_view_backend() [1/2]

threadschedule::detail::thread_view_backend::thread_view_backend ( std::thread &  t)
inline

Definition at line 600 of file thread_backend.hpp.

◆ thread_view_backend() [2/2]

threadschedule::detail::thread_view_backend::thread_view_backend ( std::thread &  t,
native_thread_id  tid 
)
inline

Definition at line 602 of file thread_backend.hpp.

Member Function Documentation

◆ get() [1/2]

auto threadschedule::detail::thread_view_backend::get ( ) const -> std::thread const&
inlinenoexcept

Definition at line 614 of file thread_backend.hpp.

◆ get() [2/2]

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

Definition at line 609 of file thread_backend.hpp.


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