libsidplayfp  2.0.2
Public Member Functions | List of all members
libsidplayfp::EventScheduler Class Reference

#include <EventScheduler.h>

Public Member Functions

void schedule (Event &event, unsigned int cycles, event_phase_t phase)
 
void schedule (Event &event, unsigned int cycles)
 
void cancel (Event &event)
 
void reset ()
 
void clock ()
 
bool isPending (Event &event) const
 
event_clock_t getTime (event_phase_t phase) const
 
event_clock_t getTime (event_clock_t clock, event_phase_t phase) const
 
event_phase_t phase () const
 

Detailed Description

Fast EventScheduler, which maintains a linked list of Events. This scheduler takes neglible time even when it is used to schedule events for nearly every clock.

Events occur on an internal clock which is 2x the visible clock. The visible clock is divided to two phases called phi1 and phi2.

The phi1 clocks are used by VIC and CIA chips, phi2 clocks by CPU.

Scheduling an event for a phi1 clock when system is in phi2 causes the event to be moved to the next phi1 cycle. Correspondingly, requesting a phi1 time when system is in phi2 returns the value of the next phi1.

Member Function Documentation

◆ cancel()

void libsidplayfp::EventScheduler::cancel ( Event event)

Cancel event if pending.

Parameters
eventthe event to cancel

◆ clock()

void libsidplayfp::EventScheduler::clock ( )
inline

Fire next event, advance system time to that event.

◆ getTime() [1/2]

event_clock_t libsidplayfp::EventScheduler::getTime ( event_clock_t  clock,
event_phase_t  phase 
) const
inline

Get clocks since specified clock in given phase.

Parameters
clockthe time to compare to
phasethe phase to comapre to
Returns
the time between specified clock and now

◆ getTime() [2/2]

event_clock_t libsidplayfp::EventScheduler::getTime ( event_phase_t  phase) const
inline

Get time with respect to a specific clock phase.

Parameters
phasethe phase
Returns
the time according to specified phase.

◆ isPending()

bool libsidplayfp::EventScheduler::isPending ( Event event) const

Check if an event is in the queue.

Parameters
eventthe event
Returns
true when pending

◆ phase()

event_phase_t libsidplayfp::EventScheduler::phase ( ) const
inline

Return current clock phase.

Returns
The current phase

◆ reset()

void libsidplayfp::EventScheduler::reset ( )

Cancel all pending events and reset time.

◆ schedule() [1/2]

void libsidplayfp::EventScheduler::schedule ( Event event,
unsigned int  cycles 
)
inline

Add event to pending queue in the same phase as current event.

Parameters
eventthe event to add
cycleshow many cycles from now to fire

◆ schedule() [2/2]

void libsidplayfp::EventScheduler::schedule ( Event event,
unsigned int  cycles,
event_phase_t  phase 
)
inline

Add event to pending queue.

At PHI2, specify cycles=0 and Phase=PHI1 to fire on the very next PHI1.

Parameters
eventthe event to add
cycleshow many cycles from now to fire
phasethe phase when to fire the event

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