Hegel 0.13.1
Property-based testing for C++
Loading...
Searching...
No Matches
hegel::stateful::ConcurrentPool< T > Class Template Reference

A pool of values that concurrent workers can share. More...

#include <stateful.h>

Public Member Functions

 ConcurrentPool (const TestCase &tc)
 Creates an empty pool.
void add (const TestCase &tc, T value)
 Adds a value to the pool.
bool empty () const
 Returns true if the pool contains no values.
std::size_t size () const
 Returns the number of values in the pool.
 ConcurrentPool (const ConcurrentPool &)=delete
ConcurrentPool & operator= (const ConcurrentPool &)=delete

Friends

class ConcurrentVariablesGenerator< T >

Detailed Description

template<typename T>
class hegel::stateful::ConcurrentPool< T >

A pool of values that concurrent workers can share.

Store the pool in a concurrent state machine. Use add to add a value from a worker, values_reusable to draw a copy without removal, and values_consumed to draw and remove a value.

libhegel selects a value and updates the pool as an atomic operation. A draw rejects the test case if the pool is empty.

A ConcurrentPool is not copyable.

Template Parameters
TThe type of the values in the pool

Constructor & Destructor Documentation

◆ ConcurrentPool()

template<typename T>
hegel::stateful::ConcurrentPool< T >::ConcurrentPool ( const TestCase & tc)
inlineexplicit

Creates an empty pool.

Parameters
tcThe test case

Member Function Documentation

◆ add()

template<typename T>
void hegel::stateful::ConcurrentPool< T >::add ( const TestCase & tc,
T value )
inline

Adds a value to the pool.

Call with the test case of the current worker.

Parameters
tcThe test case of the current worker
valueThe value to add

◆ empty()

template<typename T>
bool hegel::stateful::ConcurrentPool< T >::empty ( ) const
inline

Returns true if the pool contains no values.

Returns
True if the pool contains no values

◆ size()

template<typename T>
std::size_t hegel::stateful::ConcurrentPool< T >::size ( ) const
inline

Returns the number of values in the pool.

Returns
The number of values in the pool

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