88 template <
typename Predicate>
90 : config_(cfg), stop_(false), worker_([this, pred]() { run_loop(pred); })
97 if (worker_.joinable())
105 template <
typename Predicate>
106 void run_loop(Predicate pred)
108 std::mt19937 rng(std::random_device{}());
117 if (config_.shuffle_affinity)
123 static_cast<int>(idx % (topo.numa_nodes > 0 ? topo.numa_nodes : 1)),
static_cast<int>(idx));
130 if (config_.priority_jitter != 0)
132 std::uniform_int_distribution<int> dist(-config_.priority_jitter, config_.priority_jitter);
134 int delta = dist(rng);
141 std::this_thread::sleep_for(config_.interval);
146 std::atomic<bool> stop_;
ChaosController(ChaosController const &)=delete
ChaosController(ChaosConfig cfg, Predicate pred)
auto operator=(ChaosController const &) -> ChaosController &=delete
Manages a set of CPU indices to which a thread may be bound.
Value-semantic wrapper for a thread scheduling priority.
static constexpr auto normal() noexcept -> ThreadPriority
auto affinity_for_node(int node_index, int thread_index, int threads_per_node=1) -> ThreadAffinity
Build a ThreadAffinity for the given NUMA node.
auto registry() -> ThreadRegistry &
Returns a reference to the process-wide ThreadRegistry.
auto read_topology() -> CpuTopology
Discover basic topology. Linux: reads /sys for NUMA nodes. Windows: single node, sequential CPU indic...
Scheduling policies, thread priority, and CPU affinity types.
Plain value type holding runtime chaos-testing parameters.
int priority_jitter
+/- range applied around the current thread priority each interval.
std::chrono::milliseconds interval
Snapshot of metadata for a single registered thread.
Process-wide thread registry, control blocks, and composite registry.
Enhanced thread wrappers: ThreadWrapper, JThreadWrapper, and non-owning views.
Hardware topology helpers (CPU count, NUMA nodes) and affinity builders.