NDEVR
API Documentation
ConcurrentOperation

Contains thread-safe operations for inter-thread logic Increment and Decrement can be used to safely add to a shared uint04 value. More...

Static Public Member Functions

static uint04 decrement (volatile uint04 &value)
 Atomically decrements a shared value by one.
static uint04 increment (volatile uint04 &value)
 Atomically increments a shared value by one.
static void notify (void *object)
 Wakes one thread waiting on the given object.
static void notifyAll (void *object)
 Wakes all threads waiting on the given object.
template<class t_type, class t_function_type>
static void ParallelGrainSort (t_type *data, uint04 len, uint04 grain_size, const t_function_type &function)
 Recursively sorts an array in parallel, splitting work into async tasks when the array exceeds the grain size, then merging the sorted halves.
template<class t_type, class t_function_type>
static void ParallelSort (t_type *data, uint04 len, t_function_type function)
 Sorts an array in parallel using a default grain size.
static void wait (void *object, std::unique_lock< std::mutex > &lock)
 Blocks the calling thread until notified on the given object.
static void wait (void *object, uint08 time, std::unique_lock< std::mutex > &lock)
 Blocks the calling thread until notified or until the timeout elapses.

Detailed Description

Contains thread-safe operations for inter-thread logic Increment and Decrement can be used to safely add to a shared uint04 value.


Also contains sort, wait, and notify functions.

See also
Thread, RWLock

Definition at line 46 of file ConcurrentOperation.h.

Member Function Documentation

◆ decrement()

uint04 ConcurrentOperation::decrement ( volatile uint04 & value)
static

Atomically decrements a shared value by one.

Parameters
[in]valueThe volatile shared integer to decrement.
Returns
The value before decrementing.

◆ increment()

uint04 ConcurrentOperation::increment ( volatile uint04 & value)
static

Atomically increments a shared value by one.

Parameters
[in]valueThe volatile shared integer to increment.
Returns
The value before incrementing.

Referenced by BasicThread::ThreadLoop().

◆ notify()

void ConcurrentOperation::notify ( void * object)
static

Wakes one thread waiting on the given object.

Parameters
[in]objectThe object whose waiting thread should be notified.

◆ notifyAll()

void ConcurrentOperation::notifyAll ( void * object)
static

Wakes all threads waiting on the given object.

Parameters
[in]objectThe object whose waiting threads should be notified.

◆ ParallelGrainSort()

template<class t_type, class t_function_type>
void ConcurrentOperation::ParallelGrainSort ( t_type * data,
uint04 len,
uint04 grain_size,
const t_function_type & function )
inlinestatic

Recursively sorts an array in parallel, splitting work into async tasks when the array exceeds the grain size, then merging the sorted halves.

Parameters
[in]dataPointer to the array to sort.
[in]lenThe number of elements in the array.
[in]grain_sizeThe minimum partition size below which sorting falls back to std::sort.
[in]functionThe comparison function used for ordering elements.

Definition at line 104 of file ConcurrentOperation.h.

References ParallelGrainSort().

Referenced by ParallelGrainSort(), and ParallelSort().

◆ ParallelSort()

template<class t_type, class t_function_type>
void ConcurrentOperation::ParallelSort ( t_type * data,
uint04 len,
t_function_type function )
inlinestatic

Sorts an array in parallel using a default grain size.

Parameters
[in]dataPointer to the array to sort.
[in]lenThe number of elements in the array.
[in]functionThe comparison function used for ordering elements.

Definition at line 91 of file ConcurrentOperation.h.

References getMax(), and ParallelGrainSort().

◆ wait() [1/2]

void ConcurrentOperation::wait ( void * object,
std::unique_lock< std::mutex > & lock )
static

Blocks the calling thread until notified on the given object.

Parameters
[in]objectThe object to wait on, used as a key for notification.
[in]lockThe unique lock that is released while waiting and reacquired on wake.

◆ wait() [2/2]

void ConcurrentOperation::wait ( void * object,
uint08 time,
std::unique_lock< std::mutex > & lock )
static

Blocks the calling thread until notified or until the timeout elapses.

Parameters
[in]objectThe object to wait on, used as a key for notification.
[in]timeThe maximum wait time in milliseconds.
[in]lockThe unique lock that is released while waiting and reacquired on wake.

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