libcaf  0.16.0
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,
  opencl_manager,
  openssl_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. More...
 
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. More...
 
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. More...
 
void inline_all_enqueues ()
 Executes all enqueued jobs immediately by using the after_next_enqueue hook. More...
 
bool detaches_utility_actors () const override
 Returns true if this scheduler detaches its utility actors.
 
detail::test_actor_clock & clock () noexcept override
 
std::pair< size_t, size_t > run_dispatch_loop (timespan cycle_duration=timespan{1}) CAF_DEPRECATED_MSG("use the testing DSL's run() instead")
 
- 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_systemsystem ()
 
const actor_system_configconfig () 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. More...
 
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_systemsystem_
 Reference to the host system.
 

Detailed Description

A schedule coordinator for testing purposes.

Member Function Documentation

◆ inline_all_enqueues()

void caf::scheduler::test_coordinator::inline_all_enqueues ( )

Executes all enqueued jobs immediately by using the after_next_enqueue hook.

◆ inline_next_enqueue()

void caf::scheduler::test_coordinator::inline_next_enqueue ( )

Executes the next enqueued job immediately by using the after_next_enqueue hook.

◆ 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.


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