C++ Actor Framework 0.18
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | Protected Member Functions | List of all members
caf::scheduler::test_coordinator Class Reference

A schedule coordinator for testing purposes. More...

#include <test_coordinator.hpp>

Inheritance diagram for caf::scheduler::test_coordinator:
caf::scheduler::abstract_coordinator caf::actor_system::module

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 ,
  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... Ts>
decltype(auto) 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.
 
virtual void enqueue (resumable *what)=0
 Puts what into the queue of a randomly chosen worker.
 
actor_systemsystem ()
 
const actor_system_configconfig () const
 
size_t max_throughput () const
 
size_t num_workers () const
 
virtual bool detaches_utility_actors () const
 Returns true if this scheduler detaches its utility actors.
 
void start () override
 Starts any background threads needed by the module.
 
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.
 
virtual actor_clockclock () noexcept=0
 
- Public Member Functions inherited from caf::actor_system::module
const char * name () const noexcept
 Returns the human-redable name of the module.
 
virtual void start ()=0
 Starts any background threads needed by the module.
 
virtual void stop ()=0
 Stops all background threads of the module.
 
virtual void init (actor_system_config &)=0
 Allows the module to change the configuration of the actor system during startup.
 
virtual id_t id () const =0
 Returns the identifier of this module.
 
virtual void * subtype_ptr ()=0
 Returns a pointer to the subtype.
 

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 *)
 
static size_t default_thread_count () noexcept
 
- 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_systemsystem_
 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 ( )
overridevirtualnoexcept

◆ detaches_utility_actors()

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

Returns true if this scheduler detaches its utility actors.

Reimplemented from caf::scheduler::abstract_coordinator.

◆ enqueue()

void caf::scheduler::test_coordinator::enqueue ( resumable what)
overrideprotectedvirtual

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 ( )
overrideprotectedvirtual

Starts any background threads needed by the module.

Reimplemented from caf::scheduler::abstract_coordinator.

◆ stop()

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

Stops all background threads of the module.

Implements caf::actor_system::module.


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