SSP21-CPP
Classes | Public Member Functions | List of all members
exe4cpp::MockExecutor Class Referencefinal

#include <exe4cpp/MockExecutor.h>

Public Member Functions

virtual Timer start (const duration_t &delay, const action_t &action) override
 
virtual Timer start (const steady_time_t &time, const action_t &action) override
 
virtual void post (const action_t &action) override
 
virtual steady_time_t get_time () override
 
bool run_one ()
 
size_t run_many (size_t maximum=std::numeric_limits< size_t >::max())
 
size_t num_active () const
 
size_t num_pending_timers () const
 
steady_time_t next_timer_expiration_abs () const
 
duration_t next_timer_expiration_rel () const
 
size_t advance_time (duration_t duration)
 
void add_time (duration_t duration)
 
bool advance_to_next_timer ()
 
size_t num_timer_cancel () const
 

Detailed Description

Mock implementation of IExecutor for testing

Definition at line 42 of file MockExecutor.h.

Member Function Documentation

◆ start() [1/2]

virtual Timer exe4cpp::MockExecutor::start ( const duration_t &  duration,
const action_t &  action 
)
inlineoverridevirtual
Returns
start a new timer based on a relative time duration

Implements exe4cpp::IExecutor.

Definition at line 78 of file MockExecutor.h.

◆ start() [2/2]

virtual Timer exe4cpp::MockExecutor::start ( const steady_time_t &  expiration,
const action_t &  action 
)
inlineoverridevirtual
Returns
start a new timer based on an absolute timestamp of the steady clock

Implements exe4cpp::IExecutor.

Definition at line 83 of file MockExecutor.h.

◆ post()

virtual void exe4cpp::MockExecutor::post ( const action_t &  action)
inlineoverridevirtual
Returns
Thread-safe way to post an event to be handled asynchronously

Implements exe4cpp::IExecutor.

Definition at line 90 of file MockExecutor.h.

◆ get_time()

virtual steady_time_t exe4cpp::MockExecutor::get_time ( )
inlineoverridevirtual
Returns
a non-absolute timestamp for the monotonic time source

Implements exe4cpp::ISteadyTimeSource.

Definition at line 95 of file MockExecutor.h.

◆ run_one()

bool exe4cpp::MockExecutor::run_one ( )
inline
Returns
true if an action was run.

Definition at line 101 of file MockExecutor.h.

◆ run_many()

size_t exe4cpp::MockExecutor::run_many ( size_t  maximum = std::numeric_limits<size_t>::max())
inline

Calls RunOne() up to some maximum number of times continuing while there are still events to dispatch

Returns
the number of events dispatched

Definition at line 123 of file MockExecutor.h.

◆ num_active()

size_t exe4cpp::MockExecutor::num_active ( ) const
inline
Returns
The number of active, pending timers and post operations

Definition at line 131 of file MockExecutor.h.