CScheduler

Schedules deferred and recurring background tasks.

Synopsis

Declared in <scheduler.h>

class CScheduler;

Type Aliases

NameDescription
Function Callable type for scheduled tasks.

Member Functions

NameDescription
CScheduler [constructor]Constructs an idle scheduler with an empty task queue.
~CScheduler [destructor]Destroys the scheduler; the service thread must already be stopped.
AreThreadsServicingQueue Returns true if there are threads actively running in serviceQueue()
MockForward Mock the scheduler to fast forward in time. Iterates through items on taskQueue and reschedules them to be delta_seconds sooner.
StopWhenDrained Tell any threads running serviceQueue to stop when there is no work left to be done
getQueueInfo Returns number of tasks waiting to be serviced, and first and last task times
schedule Call func at/after time t
scheduleEvery Repeat f until the scheduler is stopped. First run is after delta has passed once.
scheduleFromNow Call f once after the delta has passed
serviceQueue scheduler Services the queue 'forever'. Should be run in a thread.
stop Tell any threads running serviceQueue to stop as soon as the current task is done

Data Members

NameDescription
m_service_thread Thread running serviceQueue(), if the scheduler was started on its own thread.