Woman, Life, Freedom


Adaptive AUTOSAR
ARA public interface header documentation
ara::exec::DeterministicClient Class Referencefinal

Class that utilizes a client to have deterministic behaviour. More...

#include <deterministic_client.h>

Public Types

using TimeStamp = std::chrono::time_point< std::chrono::steady_clock >
 Steady clock time point for deterministic cycles.
 

Public Member Functions

core::Result< ActivationReturnTypeWaitForActivation ()
 Blocks the caller till reaching the next activation time. More...
 
template<typename ValueType , typename Container >
ara::core::Result< void > RunWorkerPool (WorkerRunnable< ValueType > &runnableObj, Container &container) noexcept
 Run a deterministic worker pool to process a container via a runnable object. More...
 
uint64_t GetRandom () noexcept
 Get a deterministic random number. More...
 
void SetRandomSeed (uint64_t seed) noexcept
 Set a seed number to the deterministic random number generator. More...
 
core::Result< TimeStampGetActivationTime () noexcept
 Get the last activation time. More...
 
core::Result< TimeStampGetNextActivationTime ()
 Get the next comming activation time. More...
 

Static Public Attributes

static const uint64_t cCycleDelayMs {10}
 Theoretical cyclic delay in millisecond.
 

Detailed Description

Class that utilizes a client to have deterministic behaviour.

Member Function Documentation

◆ GetActivationTime()

core::Result< DeterministicClient::TimeStamp > ara::exec::DeterministicClient::GetActivationTime ( )
noexcept

Get the last activation time.

Returns
Last time that WaitForActivation returns ActivationReturnType::kRun

◆ GetNextActivationTime()

core::Result< DeterministicClient::TimeStamp > ara::exec::DeterministicClient::GetNextActivationTime ( )

Get the next comming activation time.

Returns
Time that WaitForActivation returns ActivationReturnType::kRun at a new cycle

◆ GetRandom()

uint64_t ara::exec::DeterministicClient::GetRandom ( )
noexcept

Get a deterministic random number.

Returns
Identical random number till the next activation cycle

◆ RunWorkerPool()

template<typename ValueType , typename Container >
ara::core::Result< void > ara::exec::DeterministicClient::RunWorkerPool ( WorkerRunnable< ValueType > &  runnableObj,
Container &  container 
)
inlinenoexcept

Run a deterministic worker pool to process a container via a runnable object.

It uses the pool to iterate over each container element and call WorkerRunnable::Run of the runnable object for each of them.

Template Parameters
ValueTypeContainer element type
ContainerContainer type which supports standard iterator operators (e.g., begin and end)
Parameters
runnableObjObject to process container elements
containerWrapper around the elements that the WorkerRunnable should process
Returns
Void Result if running the pool was successful, otherwise Result which contains the occurred error

◆ SetRandomSeed()

void ara::exec::DeterministicClient::SetRandomSeed ( uint64_t  seed)
noexcept

Set a seed number to the deterministic random number generator.

Parameters
seedRandom number seed

◆ WaitForActivation()

core::Result< ActivationReturnType > ara::exec::DeterministicClient::WaitForActivation ( )

Blocks the caller till reaching the next activation time.

Returns
Value that controls the caller's internal lifecylce