libcaf  0.15.5
Classes | 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

Classes

struct  delayed_msg
 A scheduled message or timeout. More...
 

Public Types

using super = abstract_coordinator
 
using hrc = std::chrono::high_resolution_clock
 A clock type using the highest available precision.
 
- Public Types inherited from caf::scheduler::abstract_coordinator
enum  utility_actor_id : size_t {
  printer_id,
  timer_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 dispatch_once ()
 Tries to dispatch a single delayed message.
 
size_t dispatch ()
 Dispatches all pending delayed messages. More...
 
std::pair< size_t, size_t > run_dispatch_loop ()
 Loops until no job or delayed message remains. More...
 
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.
 
- 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.
 
actor timer () const
 Returns a handle to the central timer actor.
 
size_t num_utility_actors () const
 Returns the number of utility actors.
 
template<class Duration , class... Data>
void delayed_send (Duration rel_time, strong_actor_ptr from, strong_actor_ptr to, message_id mid, message data)
 
actor_systemsystem ()
 
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 Attributes

std::deque< resumable * > jobs
 A double-ended queue representing our current job queue.
 
std::multimap< hrc::time_point, delayed_msgdelayed_messages
 A map type for storing scheduled messages and timeouts.
 

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_
 
size_t max_throughput_
 
size_t num_workers_
 
std::array< actor, max_id > utility_actors_
 
actor_systemsystem_
 

Detailed Description

A schedule coordinator for testing purposes.

Member Function Documentation

size_t caf::scheduler::test_coordinator::dispatch ( )

Dispatches all pending delayed messages.

Returns the number of dispatched messages.

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

Executes all enqueued jobs immediately by using the after_next_enqueue hook.

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

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

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.

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.

std::pair<size_t, size_t> caf::scheduler::test_coordinator::run_dispatch_loop ( )

Loops until no job or delayed message remains.

Returns the total number of events (first) and dispatched delayed messages (second).


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