Interface ScheduledEvent

All Known Implementing Classes:
AllocatorFreeEvent, EventExample

public interface ScheduledEvent
Interface for events that can be scheduled using the EventScheduler.

Example:
import com.softsynth.jmsl.*;


public class EventExample implements ScheduledEvent {

        private String msg;
        private double playTime;
        
        public EventExample(double playTime, String msg) {
                this.msg = msg;
                this.playTime = playTime;
        }
        
        public double getPlayTime() {
                return playTime;
        }
        
        public void play() {
                JMSL.out.println(msg + ", firing at playTime: " + playTime + ", scheduling error: " + (JMSL.now()-playTime));
        }
        

        public static void main(String args[]) {
                EventScheduler scheduler = new EventScheduler();
                scheduler.start();
                scheduler.post(new EventExample(JMSL.now() + 4.0, "Ho there"));
                scheduler.post(new EventExample(JMSL.now() + 3.0, "Hi there"));
                scheduler.post(new EventExample(JMSL.now() + 2.0, "Hey there"));
        }
        
}
Author:
Phil Burk and Nick Didkovsky
See Also:
EventScheduler
  • Method Summary

    Modifier and Type Method Description
    double getPlayTime()  
    void play()
    Called by EventScheduler to cause event to happen.
  • Method Details

    • getPlayTime

      double getPlayTime()
      Returns:
      time that the event should occur.
    • play

      void play()
      Called by EventScheduler to cause event to happen.