Go to the first, previous, next, last section, table of contents.


CNEventHeapSched -- Event Scheduler using a heap

SYNOPSIS

#include <CNCL/EventHeapSched.h>

TYPE

CN_EVENTHEAPSCHED

BASE CLASSES

CNEventBaseSched

DERIVED CLASSES

None

RELATED CLASSES

CNEvent, CNEventHandler, CNEventScheduler

DESCRIPTION

CNEventHeapSched is a replacement for CNEventScheduler. From the user's point of view, it is completely compatible, but it differs in the internally used datastructures and algorithms.

If a high number of events is used simultaneously, the eventlist used in CNEventScheduler can become very slow. CNEventHeapSched solves that problem by using a more efficient algorithm, a "heap".

However there is one drawback with CNEventHeapSched: in contrast to CNEventScheduler no FIFO order of processing can be guaranteed if events compare equal. If there are for example two or more events with exactly the same scheduled simulation time and the same priority, then they are processed in random order.

Constructors:

CNEventHeapSched();
CNEventHeapSched(CNParam *param);
Initializes the event scheduler.

In addition to the member functions required by CNCL, CNEventHeapSched provides:

void add_event(CNEvent *ev);
void send_event(CNEvent *ev);
Adds/sends an event to an event handler.
void delete_event(CNEventID id);
Deletes event with ID id.
void delete_events(CNEventHandler *evh, bool to=TRUE);
Deletes all events from the list that are addressed to or are comming from event handler evh.
CNEvent *peek_event();
CNEvent *peek_event(CNEventID id);
Peeks at next event or event with ID id. Returns pointer to event, or NIL if not available.
CNEvent *next_event();
Gets (and removes) the next CNEvent from the current heap.
void stop();
Stops the scheduler after processing the current event and deletes all pending events in the event list. May be used inside an event handler to stop the simulation.
CNEventIterator *create_iterator();
Creates an iterator object to traverse the list of events.


Go to the first, previous, next, last section, table of contents.