libsidplayfp  0.3.5
Public Member Functions | Protected Member Functions | List of all members
EventScheduler Class Reference

#include <event.h>

Inheritance diagram for EventScheduler:
EventContext

Public Member Functions

void reset (void)
void clock (void)
event_clock_t getTime (const event_phase_t phase) const
event_clock_t getTime (const event_clock_t clock, const event_phase_t phase) const
event_phase_t phase () const

Protected Member Functions

void schedule (Event &event, const event_clock_t cycles, const event_phase_t phase)
void schedule (Event &event, const event_clock_t cycles)
void cancel (Event &event)

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 cycle. (This behavior may be a bug of the original EventScheduler specification. Likely reason is to avoid scheduling an event into past.)

Getting a phi1 time when system is in phi2 causes the next phi1 clock to be returned.

To make scheduling even faster, I am considering making event cancellation before rescheduling mandatory, as caller is generally in position to automatically know if the event needs to be canceled first.

Author
Antti S. Lankila

Member Function Documentation

void EventScheduler::cancel ( Event event)
protectedvirtual

Cancel the specified event.

Parameters
eventthe event to cancel

Implements EventContext.

void EventScheduler::clock ( void  )
inline

Fire next event, advance system time to that event

event_clock_t EventScheduler::getTime ( const event_phase_t  phase) const
inlinevirtual

Get time with respect to a specific clock phase

Parameters
phasethe phase
Returns
the time according to specified phase.

Implements EventContext.

event_clock_t EventScheduler::getTime ( const event_clock_t  clock,
const event_phase_t  phase 
) const
inlinevirtual

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

Implements EventContext.

event_phase_t EventScheduler::phase ( ) const
inlinevirtual

Return current clock phase

Returns
The current phase

Implements EventContext.

void EventScheduler::reset ( void  )

Cancel all pending events and reset time.

void EventScheduler::schedule ( Event event,
const event_clock_t  cycles,
const event_phase_t  phase 
)
inlineprotectedvirtual

Add event to pending queue.

Parameters
eventthe event to add
cyclesthe clock to fire
phasewhen to fire the event

Implements EventContext.

void EventScheduler::schedule ( Event event,
const event_clock_t  cycles 
)
inlineprotectedvirtual

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

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

Implements EventContext.


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