Loading...
Searching...
No Matches
caf::scheduler::test_coordinator Class Reference

A schedule coordinator for testing purposes. More...

`#include <test_coordinator.hpp>`

Inheritance diagram for caf::scheduler::test_coordinator:

## Public Types

using | super = abstract_coordinator
using | bool_predicate = std::function<bool()>
| A type-erased boolean predicate.
Public Types inherited from caf::scheduler::abstract_coordinator
enum | utility_actor_id : size_t { printer_id , max_id }
Public Types inherited from caf::actor_system::module
enum | id_t { scheduler , middleman , opencl_manager , openssl_manager , network_manager , num_ids }

## Public Member Functions

| test_coordinator (actor_system &sys)
bool | has_job () const
| Returns whether at least one job is in the queue.
template<class T = resumable>
T & | next_job ()
| Returns the next element from the job queue as type T.
template<class T>
const T & | peek ()
| Peeks into the mailbox of next_job<scheduled_actor>().
template<class Handle>
bool | prioritize (const Handle &x)
| Puts x at the front of the queue unless it cannot be found in the queue.
template<class Predicate>
size_t | run_jobs_filtered (Predicate predicate)
| Runs all jobs that satisfy the predicate.
bool | try_run_once ()
| Tries to execute a single event in FIFO order.
bool | try_run_once_lifo ()
| Tries to execute a single event in LIFO order.
void | run_once ()
| Executes a single event in FIFO order or fails if no event is available.
void | run_once_lifo ()
| Executes a single event in LIFO order or fails if no event is available.
size_t | run (size_t max_count=std::numeric_limits< size_t >::max())
| Executes events until the job queue is empty and no pending timeouts are left.
bool | has_pending_timeout () const
| Returns whether at least one pending timeout exists.
bool | trigger_timeout ()
| Tries to trigger a single timeout.
size_t | trigger_timeouts ()
| Triggers all pending timeouts.
size_t | advance_time (timespan x)
| Advances simulation time and returns the number of triggered timeouts.
template<class F>
void | after_next_enqueue (F f)
void | inline_next_enqueue ()
| Executes the next enqueued job immediately by using the after_next_enqueue hook.
void | inline_all_enqueues ()
| Executes all enqueued jobs immediately by using the after_next_enqueue hook.
bool | detaches_utility_actors () const override
| Returns true if this scheduler detaches its utility actors.
detail::test_actor_clock & | clock () noexcept override
Public Member Functions inherited from caf::scheduler::abstract_coordinator
| abstract_coordinator (actor_system &sys)
actor | printer () const
| Returns a handle to the central printing actor.
size_t | num_utility_actors () const
| Returns the number of utility actors.
actor_system & | system ()
const actor_system_config & | config () const
size_t | max_throughput () const
size_t | num_workers () const
void | init (actor_system_config &cfg) override
| Allows the module to change the configuration of the actor system during startup.
id_t | id () const override
| Returns the identifier of this module.
void * | subtype_ptr () override
| Returns a pointer to the subtype.
Public Member Functions inherited from caf::actor_system::module
const char * | name () const noexcept
| Returns the human-redable name of the module.

## Public Attributes

std::deque< resumable * > | jobs
| A double-ended queue representing our current job queue.

## Protected Member Functions

void | start () override
| Starts any background threads needed by the module.
void | stop () override
| Stops all background threads of the module.
void | enqueue (resumable *ptr) override
| Puts what into the queue of a randomly chosen worker.
Protected Member Functions inherited from caf::scheduler::abstract_coordinator
void | stop_actors ()

## Additional Inherited Members

Static Public Member Functions inherited from caf::scheduler::abstract_coordinator
static void | cleanup_and_release (resumable *)
Protected Attributes inherited from caf::scheduler::abstract_coordinator
std::atomic< size_t > | next_worker_
| ID of the worker receiving the next enqueue (round-robin dispatch).
size_t | max_throughput_
| Number of messages each actor is allowed to consume per resume.
size_t | num_workers_
| Configured number of workers.
std::array< actor, max_id > | utility_actors_
| Background workers, e.g., printer.
actor_system & | system_
| Reference to the host system.

## Detailed Description

A schedule coordinator for testing purposes.

## Member Function Documentation

## clock()

detail::test_actor_clock & caf::scheduler::test_coordinator::clock | ( |  | ) |

override virtual noexcept

Implements caf::scheduler::abstract_coordinator.

## detaches_utility_actors()

bool caf::scheduler::test_coordinator::detaches_utility_actors | ( |  | ) | const

override virtual

Returns true if this scheduler detaches its utility actors.

Reimplemented from caf::scheduler::abstract_coordinator.

## enqueue()

void caf::scheduler::test_coordinator::enqueue | ( | resumable * | what | ) |

override protected virtual

Puts what into the queue of a randomly chosen worker.

Implements caf::scheduler::abstract_coordinator.

## prioritize()

template<class Handle>

bool caf::scheduler::test_coordinator::prioritize | ( | const Handle & | x | ) |

Puts x at the front of the queue unless it cannot be found in the queue.

Returns true if x exists in the queue and was put in front, false otherwise.

## run()

size_t caf::scheduler::test_coordinator::run | ( | size_t | max_count = std::numeric_limits< size_t >::max() | ) |

Executes events until the job queue is empty and no pending timeouts are left.

Returns the number of processed events.

## start()

void caf::scheduler::test_coordinator::start | ( |  | ) |

override protected virtual

Starts any background threads needed by the module.

Reimplemented from caf::scheduler::abstract_coordinator.

## stop()

void caf::scheduler::test_coordinator::stop | ( |  | ) |

override protected virtual

Stops all background threads of the module.

Implements caf::actor_system::module.

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

- /build/actor-framework-Z9pIPl/actor-framework-0.17.6/libcaf_core/caf/scheduler/test_coordinator.hpp