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

RAII controller that periodically perturbs scheduling attributes of registered threads for chaos/fuzz testing. More...

#include <chaos.hpp>

Public Member Functions

template<typename Predicate>
 ChaosController (ChaosConfig cfg, Predicate pred)
 ChaosController (ChaosController const &)=delete
auto operator= (ChaosController const &) -> ChaosController &=delete

Detailed Description

RAII controller that periodically perturbs scheduling attributes of registered threads for chaos/fuzz testing.

On construction, ChaosController spawns a background std::thread that wakes every ChaosConfig::interval and applies perturbations (affinity shuffling, priority jitter) to threads in the global registry() that match the user-supplied predicate.

Ownership semantics:

  • Non-copyable, non-movable.
  • The destructor signals the worker to stop and blocks until it joins. Do not destroy from a context where blocking is unacceptable.

Thread safety: The controller operates on the global registry(), which is internally synchronized, so multiple controllers or concurrent registrations are safe.

Warning
Intended for testing and validation only – not for production use. Perturbations may cause spurious priority inversions and cache-thrashing.
Example
ChaosConfig cfg{.interval = 100ms, .priority_jitter = 5};
ChaosController chaos(cfg, [](auto const& info) {
return info.name.starts_with("worker");
});
// ... run tests while chaos is active ...
// destructor joins the worker thread
RAII controller that periodically perturbs scheduling attributes of registered threads for chaos/fuzz...
Definition chaos.hpp:86
Plain value type holding runtime chaos-testing parameters.
Definition chaos.hpp:34
See also
ChaosConfig, registry()

Definition at line 85 of file chaos.hpp.

Constructor & Destructor Documentation

◆ ChaosController()

template<typename Predicate>
threadschedule::ChaosController::ChaosController ( ChaosConfig cfg,
Predicate pred )
inline

Definition at line 89 of file chaos.hpp.

◆ ~ChaosController()

threadschedule::ChaosController::~ChaosController ( )
inline

Definition at line 94 of file chaos.hpp.


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