|
| | thread_registry_backend ()=default |
| | ~thread_registry_backend () |
| | thread_registry_backend (thread_registry_backend const &)=delete |
| auto | operator= (thread_registry_backend const &) -> thread_registry_backend &=delete |
| void | register_current_thread (std::string name=std::string(), std::string component=std::string()) |
| void | register_current_thread (std::shared_ptr< thread_control_block > const &control_block, std::string name=std::string(), std::string component=std::string()) |
| void | unregister_current_thread () |
| auto | get (native_thread_id tid) const -> std::optional< registered_thread_info_backend > |
| auto | query () const -> query_view |
| auto | set_affinity (native_thread_id tid, native_thread_affinity const &affinity) const -> expected< void, std::error_code > |
| auto | set_priority (native_thread_id tid, native_thread_priority priority) const -> expected< void, std::error_code > |
| auto | set_nice_value (native_thread_id tid, int nice_value) const -> expected< void, std::error_code > |
| auto | get_nice_value (native_thread_id tid) const -> expected< int, std::error_code > |
| auto | set_scheduling_policy (native_thread_id tid, native_scheduling_policy policy, native_thread_priority priority) const -> expected< void, std::error_code > |
| auto | configure (native_thread_id tid, native_scheduling_config const &config) const -> expected< void, std::error_code > |
| auto | configure (native_thread_id tid, native_thread_config const &config) const -> expected< void, std::error_code > |
| auto | set_name (native_thread_id tid, std::string const &name) const -> expected< void, std::error_code > |
| void | update_registered_name (native_thread_id tid, std::string const &name) |
| void | set_on_register (registry_callback cb) |
| template<typename Callback, std::enable_if_t<!std::is_same_v< std::decay_t< Callback >, registry_callback >, int > = 0> |
| void | set_on_register (Callback &&cb) |
| void | set_on_unregister (registry_callback cb) |
| template<typename Callback, std::enable_if_t<!std::is_same_v< std::decay_t< Callback >, registry_callback >, int > = 0> |
| void | set_on_unregister (Callback &&cb) |
| auto | filter (Predicate &&pred) const |
| auto | count () const -> size_t |
| auto | empty () const -> bool |
| void | for_each (Fn &&fn) const |
| void | apply (Predicate &&pred, Fn &&fn) const |
| auto | map (Fn &&fn) const -> std::vector< std::invoke_result_t< Fn, registered_thread_info_backend const & > > |
| auto | find_if (Predicate &&pred) const -> std::optional< registered_thread_info_backend > |
| auto | any (Predicate &&pred) const -> bool |
| auto | all (Predicate &&pred) const -> bool |
| auto | none (Predicate &&pred) const -> bool |
| auto | take (size_t n) const |
| auto | skip (size_t n) const |
Central registry of threads indexed by OS-level thread ID (native_thread_id).
thread_registry_backend maintains a map of currently registered threads together with their metadata and optional thread_control_block handles. It provides a functional-style query API (via query_view) and convenience methods that delegate scheduling operations to each thread's control block.
- Thread safety
- All public methods are thread-safe. Internal state is protected by a
std::shared_mutex: mutating operations (register, unregister, set callbacks) acquire a unique lock, while read-only operations (get, query, set_affinity, etc.) acquire a shared lock.
- Copyability / movability
- Not copyable (copy constructor and assignment are deleted).
- Not movable (implicitly deleted because copy operations are deleted and the class holds a
std::shared_mutex).
- Registration semantics
- register_current_thread() must be called from the thread being registered. Duplicate registration of the same TID is silently ignored (the first registration wins).
- unregister_current_thread() removes the calling thread's entry and marks its
alive flag as false in the snapshot passed to the callback.
- Callbacks
- The optional
onRegister / onUnregister callbacks are invoked with the lock released to avoid deadlock if the callback itself interacts with the registry. The callback receives a copy of the registered_thread_info_backend.
- Querying
- query() returns a query_view holding a snapshot of the registry at the moment of the call. Subsequent changes to the registry (new registrations, unregistrations) are not reflected in an existing query_view. The same functional-style helpers (filter, map, for_each, etc.) are inherited from detail::query_facade_mixin.
- Scheduling helpers
- set_affinity(), set_priority(), set_scheduling_policy(), and set_name() look up the thread_control_block for the given TID under a shared lock and delegate to the control block. Returns
std::errc::no_such_process if the TID is not registered or has no control block.
Definition at line 79 of file thread_registry_backend.hpp.