ThreadSchedule 3.0.0
Modern C++ thread management library
Loading...
Searching...
No Matches
composite_thread_registry_backend.hpp
Go to the documentation of this file.
1#pragma once
2
8
9#include <mutex>
10#include <utility>
11#include <vector>
12
13namespace threadschedule
14{
48namespace detail
49{
50
51class composite_thread_registry_backend : public query_facade_mixin<composite_thread_registry_backend>
52{
53public:
54 void
56 {
57 if (reg == nullptr)
58 return;
59 std::lock_guard<std::mutex> lock(mutex_);
60 registries_.push_back(reg);
61 }
62
63 [[nodiscard]] auto
65 {
66 std::vector<registered_thread_info_backend> merged;
67 std::vector<thread_registry_backend*> regs;
68 {
69 std::lock_guard<std::mutex> lock(mutex_);
70 regs = registries_;
71 }
72 for (auto* r : regs)
73 {
74 auto view = r->query();
75 auto const& entries = view.entries();
76 merged.insert(merged.end(), entries.begin(), entries.end());
77 }
79 }
80
81private:
82 mutable std::mutex mutex_;
83 std::vector<thread_registry_backend*> registries_;
84};
85
86} // namespace detail
87} // namespace threadschedule
CRTP mixin that provides functional-style query facade methods.
auto map(Fn &&fn) const -> std::vector< std::invoke_result_t< Fn, registered_thread_info_backend const & > >
Lazy, functional-style query/filter view over a snapshot of registered threads.
Central registry of threads indexed by OS-level thread ID (native_thread_id).
Registry storage, mutation, snapshots, and private runtime hooks.