OMNeT++ Simulation Library  5.6.1
cScheduler Class Referenceabstract

#include <cscheduler.h>

Description

Abstract class to encapsulate event scheduling.

The central method is takeNextEvent().

To switch to your own scheduler class (reasons you'd like to do that include real-time simulation, hardware-in-the-loop simulation, distributed (federated) simulation, parallel distributed simulation), subclass cScheduler, register your new class with the Register_Class() macro, then add the following to omnetpp.ini:

[General]
scheduler-class = "MyClass"
Inheritance diagram for cScheduler:
cObject cISimulationLifecycleListener cRealTimeScheduler cSequentialScheduler

Public Member Functions

 cScheduler ()
 
virtual ~cScheduler ()
 
virtual std::string str () const override
 
virtual void setSimulation (cSimulation *_sim)
 
cSimulationgetSimulation () const
 
virtual void startRun ()
 
virtual void endRun ()
 
virtual void executionResumed ()
 
virtual cEventguessNextEvent ()=0
 
virtual cEventtakeNextEvent ()=0
 
virtual void putBackEvent (cEvent *event)=0
 
- Public Member Functions inherited from cObject
 cObject ()
 
 cObject (const cObject &other)
 
virtual ~cObject ()
 
virtual const char * getClassName () const
 
virtual const char * getName () const
 
bool isName (const char *s) const
 
virtual const char * getFullName () const
 
virtual std::string getFullPath () const
 
const cObjectgetThisPtr () const
 
virtual _OPPDEPRECATED std::string info () const
 
virtual _OPPDEPRECATED std::string detailedInfo () const
 
virtual cObjectdup () const
 
virtual void parsimPack (cCommBuffer *buffer) const
 
virtual void parsimUnpack (cCommBuffer *buffer)
 
virtual cObjectgetOwner () const
 
virtual bool isOwnedObject () const
 
virtual void forEachChild (cVisitor *v)
 
cObjectfindObject (const char *name, bool deep=true)
 
void copyNotSupported () const
 
- Public Member Functions inherited from cISimulationLifecycleListener
virtual ~cISimulationLifecycleListener ()
 
virtual void listenerAdded ()
 
virtual void listenerRemoved ()
 

Protected Member Functions

virtual void lifecycleEvent (SimulationLifecycleEventType eventType, cObject *details) override
 
- Protected Member Functions inherited from cObject
virtual void take (cOwnedObject *obj)
 
virtual void drop (cOwnedObject *obj)
 
void dropAndDelete (cOwnedObject *obj)
 

Additional Inherited Members

- Static Public Member Functions inherited from cISimulationLifecycleListener
static const char * getSimulationLifecycleEventName (SimulationLifecycleEventType eventType)
 

Constructor & Destructor Documentation

◆ cScheduler()

Constructor.

◆ ~cScheduler()

virtual ~cScheduler ( )
virtual

Destructor.

Member Function Documentation

◆ lifecycleEvent()

virtual void lifecycleEvent ( SimulationLifecycleEventType  eventType,
cObject details 
)
overrideprotectedvirtual

A cISimulationLifecycleListener method. Delegates to startRun(), endRun() and executionResumed(); override if needed.

Implements cISimulationLifecycleListener.

◆ str()

virtual std::string str ( ) const
overridevirtual

Return a short description. This string will be displayed in the Qtenv and Tkenv GUIs as scheduler information. Returning an empty string means "default scheduler", and is reserved for cSequentialScheduler.

Reimplemented from cObject.

Reimplemented in cRealTimeScheduler, and cSequentialScheduler.

◆ setSimulation()

virtual void setSimulation ( cSimulation _sim)
virtual

Pass cSimulation object to scheduler.

◆ getSimulation()

cSimulation* getSimulation ( ) const
inline

Returns the simulation the scheduler belongs to.

◆ startRun()

virtual void startRun ( )
inlinevirtual

Called at the beginning of a simulation run.

Reimplemented in cRealTimeScheduler.

◆ endRun()

virtual void endRun ( )
inlinevirtual

Called at the end of a simulation run.

◆ executionResumed()

virtual void executionResumed ( )
inlinevirtual

Called every time the user hits the Run button in Tkenv. Real-time schedulers (e.g. cRealTimeScheduler) may make use of this callback to pin current simulation time to current wall clock time.

Reimplemented in cRealTimeScheduler.

◆ guessNextEvent()

virtual cEvent* guessNextEvent ( )
pure virtual

Return the likely next event in the simulation. This method is for UI purposes, it does not play any role in the simulation. A basic implementation would just return a pointer to the first event in the FES, which is accurate for sequential simulation; with parallel, distributed or real-time simulation there might be other events coming from other processes with a yet smaller timestamp.

This method should not have side effects, except for discarding stale events from the FES.

Implemented in cRealTimeScheduler, and cSequentialScheduler.

◆ takeNextEvent()

virtual cEvent* takeNextEvent ( )
pure virtual

Return the next event to be processed. Normally (with sequential execution), it just returns the first event in the FES. With parallel and/or real-time simulation, it is also the scheduler's task to synchronize with real time and/or with other partitions.

If there's no more event, it throws cTerminationException.

A nullptr return value means that there's no error but execution was stopped by the user (e.g. with STOP button on the GUI) while takeNextEvent() was waiting for external synchronization.

Implemented in cRealTimeScheduler, and cSequentialScheduler.

◆ putBackEvent()

virtual void putBackEvent ( cEvent event)
pure virtual

Undo for takeNextEvent(), approximately: if an event was obtained from takeNextEvent() but was not yet processed, it is possible to temporarily put it back to the FES.

The scheduler class must guarantee that removing the event via takeNextEvent() again does NOT repeat the side effects of the first takeNextEvent()! That is, the sequence

e = takeNextEvent();
putBackEvent(e);
e = takeNextEvent();

should be equivalent to a single takeNextEvent() call.

Implemented in cRealTimeScheduler, and cSequentialScheduler.


The documentation for this class was generated from the following file: