Determinic Concurrency


Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Member Functions | List of all members
DeterministicConcurrency::UserControlledScheduler< N > Class Template Reference

A scheduler which allow to manage the flow of its managed threads. More...

#include <UserControlledScheduler.h>

Public Member Functions

thread_status_t getThreadStatus (size_t threadIndex)
 Get the Thread Status of the thread with threadIndex.
 
void joinAll ()
 Perform a join on all threads.
 
template<typename... Args>
void joinOn (Args &&... threadIndexes)
 Perform a join on the threads with threadIndexes.
 
template<typename... Args>
void proceed (Args &&... threadIndexes)
 Allow threadIndexes to continue while not stopping the scheduler thread.
 
void switchContextAll ()
 Switch context allowing all the threads to proceed while stopping the scheduler from executing until all of the threads switchContext back.
 
template<typename... Args>
void switchContextTo (Args &&... threadIndexes)
 Switch context allowing the threads with threadIndexes to proceed while stopping the scheduler from executing until all threads switchContext back.
 
template<typename... Args>
void wait (Args &&... threadIndexes)
 Wait until the threads with threadIndexes go into WAITING status.
 
template<thread_status_t S, typename... Args>
void waitUntilAllThreadStatus (Args &&... threadIndexes)
 Wait until all of the threadIndexes threads have thread_status_v equal to S.
 
template<thread_status_t S, typename... Args>
size_t waitUntilOneThreadStatus (Args &&... threadIndexes)
 Wait until at least one of the threadIndexes threads have thread_status_v equal to S and return the index of the first thread who reached S.
 

Static Public Member Functions

template<typename BasicLockable >
static void waitUntilLocked (BasicLockable *lockable)
 Wait until lockable is owned.
 

Detailed Description

template<size_t N>
class DeterministicConcurrency::UserControlledScheduler< N >

A scheduler which allow to manage the flow of its managed threads.

Member Function Documentation

◆ getThreadStatus()

template<size_t N>
thread_status_t DeterministicConcurrency::UserControlledScheduler< N >::getThreadStatus ( size_t  threadIndex)
inline

Get the Thread Status of the thread with threadIndex.

Parameters
threadIndex: Obtain the thread_status of the thread identified by threadIndex.
Returns
thread_status_t : the status of the threadIndex-th thread.

◆ joinAll()

template<size_t N>
void DeterministicConcurrency::UserControlledScheduler< N >::joinAll ( )
inline

Perform a join on all threads.

Example:

sch.joinAll();

◆ joinOn()

template<size_t N>
template<typename... Args>
void DeterministicConcurrency::UserControlledScheduler< N >::joinOn ( Args &&...  threadIndexes)
inline

Perform a join on the threads with threadIndexes.

Parameters
threadIndexes: Indexes of the threads to perform joinOn on.

Example:

sch.joinOn(0, 1, 2, 3);

◆ proceed()

template<size_t N>
template<typename... Args>
void DeterministicConcurrency::UserControlledScheduler< N >::proceed ( Args &&...  threadIndexes)
inline

Allow threadIndexes to continue while not stopping the scheduler thread.

Parameters
threadIndexes: Indexes of the threads to perform proceed on.

Example:

sch.proceed(0, 1, 2, 3);

◆ switchContextAll()

template<size_t N>
void DeterministicConcurrency::UserControlledScheduler< N >::switchContextAll ( )
inline

Switch context allowing all the threads to proceed while stopping the scheduler from executing until all of the threads switchContext back.

Example:

sch.switchContextAll();

◆ switchContextTo()

template<size_t N>
template<typename... Args>
void DeterministicConcurrency::UserControlledScheduler< N >::switchContextTo ( Args &&...  threadIndexes)
inline

Switch context allowing the threads with threadIndexes to proceed while stopping the scheduler from executing until all threads switchContext back.

Parameters
threadIndexes: Indexes of the threads to perform switchContextTo() on.

Example:

example of switchContextTo():

sch.switchContextTo(0, 1, 2, 3);

◆ wait()

template<size_t N>
template<typename... Args>
void DeterministicConcurrency::UserControlledScheduler< N >::wait ( Args &&...  threadIndexes)
inline

Wait until the threads with threadIndexes go into WAITING status.

Parameters
threadIndexes: Indexes of the threads to perform wait on.

Example:

sch.wait(0, 1, 2, 3);

◆ waitUntilAllThreadStatus()

template<size_t N>
template<thread_status_t S, typename... Args>
void DeterministicConcurrency::UserControlledScheduler< N >::waitUntilAllThreadStatus ( Args &&...  threadIndexes)
inline

Wait until all of the threadIndexes threads have thread_status_v equal to S.

Template Parameters
S: thread_status_t to wait until.
Parameters
threadIndexes: Indexes of the threads to perform waitUntilAllThreadStatus() on.

Example:

Wait until threads 0, 1, 2 and 3 reach status WAITING:

sch.waitUntilAllThreadStatus<thread_status_t::WAITING>(0,1,2,3);

◆ waitUntilLocked()

template<size_t N>
template<typename BasicLockable >
static void DeterministicConcurrency::UserControlledScheduler< N >::waitUntilLocked ( BasicLockable *  lockable)
inlinestatic

Wait until lockable is owned.

Template Parameters
BasicLockable
Parameters
lockable

Example:

std::mutex m;
sch.waitUntilLocked(&m);

◆ waitUntilOneThreadStatus()

template<size_t N>
template<thread_status_t S, typename... Args>
size_t DeterministicConcurrency::UserControlledScheduler< N >::waitUntilOneThreadStatus ( Args &&...  threadIndexes)
inline

Wait until at least one of the threadIndexes threads have thread_status_v equal to S and return the index of the first thread who reached S.

Template Parameters
S: The thread_status_t waitUntilOneThreadStatus will wait until.
Parameters
threadIndexes: Indexes of the threads to perform waitUntilOneThreadStatus() on.
Returns
size_t : the index of the first thread who reached thread_status_t S.

Example:

auto index = sch.waitUntilOneThreadStatus<thread_status_t::WAITING>(0,1,2,3);

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