Class EventScheduler

java.lang.Object
com.softsynth.jmsl.EventScheduler
All Implemented Interfaces:
java.lang.Runnable

public class EventScheduler
extends java.lang.Object
implements java.lang.Runnable
EventScheduler.java General purpose scheduler for events. This can be used for scheduling note off events, or other musical events.
Any object that implements ScheduledEvent can be posted to the event scheduler. JMSL has a static shared EventScheduler. Here is an example of posting a custom event.
 JMSL.scheduler.post(new CustomEvent(futureTime, data));
 

At futureTime the custom events play() method will be called.

MOD ND build 20060418 IMPORTANT BUG FIX! the timestamp of scheduled events is now compared to JMSL.realTime() not JMSL.now() for scheduling!
MOD ND 20070911, using wait(), wait(timeout), and notifyAll() instead of thread.sleep() and interrupt
Author:
Phil Burk and Nick Didkovsky
See Also:
ScheduledEvent
  • Field Summary

    Fields
    Modifier and Type Field Description
    static java.io.PrintWriter evLog  
    static boolean log  
  • Constructor Summary

    Constructors
    Constructor Description
    EventScheduler()  
  • Method Summary

    Modifier and Type Method Description
    static void main​(java.lang.String[] args)  
    void post​(ScheduledEvent sEvent)
    Insert the new event into a list of events in time-sorted order.
    void printTimes()  
    static int qa()  
    int qa_1()  
    int qa_2()
    run 10 events posted in ascending order
    int qa_3()
    run 10 events posted in reverse time order
    int qa_4()
    run 10 events posted in reverse time order, interrupted by a new time halfway through
    void run()  
    void start()
    Start EventScheduler thread.
    void stop()
    Stop EventScheduler thread.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • evLog

      public static java.io.PrintWriter evLog
    • log

      public static boolean log
  • Constructor Details

    • EventScheduler

      public EventScheduler()
  • Method Details

    • start

      public void start()
      Start EventScheduler thread. To prevent race conditions between threads, this object can only be started and stopped once. You must make a new EventSheduler if you need to restart.
    • stop

      public void stop()
      Stop EventScheduler thread.
    • run

      public void run()
      Specified by:
      run in interface java.lang.Runnable
    • post

      public void post​(ScheduledEvent sEvent)
      Insert the new event into a list of events in time-sorted order.
    • printTimes

      public void printTimes()
    • qa_1

      public int qa_1()
    • qa_2

      public int qa_2()
      run 10 events posted in ascending order
    • qa_3

      public int qa_3()
      run 10 events posted in reverse time order
    • qa_4

      public int qa_4()
      run 10 events posted in reverse time order, interrupted by a new time halfway through
    • qa

      public static int qa()
    • main

      public static void main​(java.lang.String[] args)