Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
concurrency_test_utils.H File Reference

Reusable helpers for concurrent data-structure tests. More...

#include <atomic>
#include <chrono>
#include <condition_variable>
#include <cstddef>
#include <cstdint>
#include <exception>
#include <initializer_list>
#include <mutex>
#include <random>
#include <system_error>
#include <thread>
#include <type_traits>
#include <utility>
#include <vector>
#include <ah-errors.H>
Include dependency graph for concurrency_test_utils.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Aleph::Testing::Deterministic_Start_Gate
 Single-use deterministic start gate for concurrent tests. More...
 
class  Aleph::Testing::detail::Joining_Thread_Guard
 RAII guard that leaves no thread joinable when it goes out of scope, cancelling gate first so any thread still blocked in Deterministic_Start_Gate::arrive_and_wait() wakes up instead of waiting forever. More...
 
struct  Aleph::Testing::Producer_Consumer_Stress_Config
 Configuration for producer/consumer stress helpers. More...
 
struct  Aleph::Testing::Producer_Consumer_Stress_Result
 Result returned by producer/consumer stress helpers. More...
 
struct  Aleph::Testing::Trace_Operation
 One randomized operation trace entry. More...
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 
namespace  Aleph::Testing
 
namespace  Aleph::Testing::detail
 

Enumerations

enum class  Aleph::Testing::Trace_Operation_Kind {
  Aleph::Testing::push , Aleph::Testing::pop , Aleph::Testing::insert , Aleph::Testing::erase ,
  Aleph::Testing::contains
}
 Operation kind for randomized reference traces. More...
 

Functions

template<typename Worker >
void Aleph::Testing::run_workers (const size_t thread_count, Worker worker)
 Launch thread_count workers with a deterministic simultaneous start, join every one of them, and rethrow the first worker exception (if any) only after all have joined.
 
template<typename Push >
bool Aleph::Testing::detail::invoke_push (Push &push, const size_t value)
 
template<typename Push , typename TryPop >
Producer_Consumer_Stress_Result Aleph::Testing::run_producer_consumer_stress (const Producer_Consumer_Stress_Config &config, Push push, TryPop try_pop)
 Run a deterministic producer/consumer stress scenario.
 
std::vector< Trace_Operation > Aleph::Testing::make_random_operation_trace (const size_t count, const uint32_t seed, const size_t key_range, const std::initializer_list< Trace_Operation_Kind > kinds={ Trace_Operation_Kind::insert, Trace_Operation_Kind::erase, Trace_Operation_Kind::contains })
 Build a deterministic pseudo-random operation trace.
 
template<typename SubjectStep , typename ReferenceStep >
std::vector< size_t > Aleph::Testing::replay_trace_and_collect_mismatches (const std::vector< Trace_Operation > &trace, SubjectStep subject_step, ReferenceStep reference_step)
 Replay a trace against a subject and a reference implementation.
 

Detailed Description

Reusable helpers for concurrent data-structure tests.

This header is test-only infrastructure. It intentionally lives under Tests/ and must not be included by production headers.

Definition in file concurrency_test_utils.H.