/* scheduler.cpp
 */


#include "sched.H"
#include "list.H"
#include "events.H"
#include "eventPQ.H"


/* Return 1 if events remain in the event queue; 0 otherwise.
 */

int 
Scheduler::events_remain()
{
    return ! events.empty();
}


/* Add an event to the event queue.
 */

void
Scheduler::add_event( Event *event )
{
    events.enqueue( event );
}

void
Scheduler::delete_event( Event *event)
{
    events.del( event );
}


/* Remove the next event from the event queue and handle it.
 */

void 
Scheduler::handle_next_event()
{
    Event *e;


    e = events.dequeue();       // Remove the event with the smallest time from					// the event queue.
    current_time = e->time;	// Update current time

    e->handle_event();		// Handle the event

    delete e;			// Delete the event
}
