scheduler


The scheduler is a class which can be used to schedule tasks. (see task_data.) There is only one scheduler, it is created by Rogus, and it can be accessed through the global pointer schedp.

class scheduler {
public:
  err_ind play_note( const MIDI_msg& on, ScheduleTime dur );
  err_ind insert( const task_data& td );
  err_ind insert( const task_data& td, task** task_return );
  err_ind cancel(task* t);
  void synchronize();
  void unsynchronize();
};
err_ind play_note( const MIDI_msg& on, ScheduleTime dur )
play_note immediately sends out on which it assumes to be a note-on. The scheduler will send out the same message, with the velocity changed to zero, dur half-milliseconds later.
err_ind insert( const task_data& td )
This is used to schedule a task_data. If you schedule a task this way, there is no way to cancel it.
err_ind insert( const task_data& td, task** task_return )
This is as above, except that you should use this version of insert if you might want to cancel the task before it happens. You should provide the address of a task*, which the scheduler will then write the address of a task into. You can pass this pointer to cancel to cancel the task.
err_ind cancel(task* t)
Cancels the task t. Returns err if t is not a valid task or if it is a task which has already happened.
void synchronize()
Performs a simple sort of locking. Only one thread may be executing between calls to synchronize and unsynchronize at once. Note that this lock is automatically acquired when callbacks for MIDI input or the scheduler are made, so calling synchronize effectively locks out callbacks. It is perfectly OK for a thread to call synchronize more than once, as long as it calls unsynchronize an equal number of times.
void unsynchronize()
Releases the lock acquired by synchronize().

Modified 29 May 1996 pepellet@mit.edu