OSDL::Engine::PeriodicSlot Class Reference

#include <OSDLPeriodicSlot.h>

List of all members.


Detailed Description

Records informations about a periodic slot.

Each of these periodic slots is internally divided into as many sub-slots as the period length. Each registered active object will be listed in at least a sub-slot.

For example, for a periodicity of 7 simulation steps, a dedicated PeriodicSlot will be created. It will be in charge of all objects registered for this periodicity, and will have internally a list of 7 sub-slots. At each new simulation tick, all objects registered in the corresponding sub-slot (whose number will be : new simulation tick % 7), will be activated.

So, at a given simulation step, all objects put in corresponding sub-slot will be activated. On the next step, the list corresponding to the next sub-slot will be activated, and so on. Each object registered in a sub-slot will therefore be activated at the right frequency, as defined in the slot, whereas not all of these objects are activated in the same simulation time, to avoid unbalanced load.

A PeriodicSlot does not have to manage simulation time internally, it therefore fully relies on the scheduler to pass it correct simulation ticks.

Note:
This object has no virtual member so that there is no 'virtual' overhead (vtable) : the scheduler will make an intensive use of it.

Definition at line 64 of file OSDLPeriodicSlot.h.

Public Member Functions

 PeriodicSlot (Events::Period periodicity) throw ()
 Creates a scheduler slot for given non-null periodicity, expressed in simulation ticks.
 ~PeriodicSlot () throw ()
 Non-virtual destructor.
void add (ActiveObject &newObject) throw ( SchedulingException )
 Adds a new active object.
void remove (ActiveObject &object) throw ( SchedulingException )
 Removes entirely an active object, possibly registered multiple time, from its slot.
void onNextTick (Events::SimulationTick newTick) throw ()
 Activates all objects registered in the slot corresponding on this new tick.
void onSimulationSkipped (Events::SimulationTick skipped) throw ( SchedulingException )
 Notices all relevant objects that specified simulation tick has to be skipped.
Events::Period getPeriod () throw ()
 Returns the period this slot is in charge of.
const std::string toString (Ceylan::VerbosityLevels level=Ceylan::high) const throw ()
 Returns an user-friendly description of the state of this object.

Protected Member Functions

Events::Period getSubSlotForSimulationTick (Events::SimulationTick tick) const throw ()
 Returns the sub-slot number corresponding to specified simulation tick.
void addInSlot (ActiveObject &newObject, Events::Period targetSlot) throw ()
 Adds explicitly in specified slot the active object.
bool removeFromSlot (ActiveObject &object, Events::Period targetSlot) throw ( SchedulingException)
 Removes from specified slot all subscriptions of the active object, and updates the slot weight.
Events::Period getLeastBusySlot () const throw ()
 Returns the first slot whose total object weights is minimal for this periodic slot.
void activateAllObjectsInSubSlot (Events::Period subSlot, Events::SimulationTick currentTime) throw ()
 Activates in turn all active objects registered in the specified slot, from the first object ever registered to the last, if they had not been activated before.

Protected Attributes

Events::Period _period
 Stores the periodicity, expressed in simulation steps, of this slot.
Events::Period _currentSlot
 Records the slot corresponding to current simulation step.
ListOfActiveObjects ** _slots
 This is an array of pointers to lists : ListOfActiveObjects * _slots[].
Weight_slotWeights
 Records the weights of all active objects registered in a slot.

Private Member Functions

 PeriodicSlot (const PeriodicSlot &source) throw ()
 Copy constructor made private to ensure that it will never be called.
PeriodicSlotoperator= (const PeriodicSlot &source) throw ()
 Assignment operator made private to ensure that it will never be called.


Constructor & Destructor Documentation

PeriodicSlot::PeriodicSlot ( Events::Period  periodicity  )  throw () [explicit]

Creates a scheduler slot for given non-null periodicity, expressed in simulation ticks.

Parameters:
periodicity the chosen periodicity.

Definition at line 14 of file OSDLPeriodicSlot.cc.

PeriodicSlot::~PeriodicSlot (  )  throw ()

Non-virtual destructor.

Definition at line 39 of file OSDLPeriodicSlot.cc.

References _period, _slots, and _slotWeights.

OSDL::Engine::PeriodicSlot::PeriodicSlot ( const PeriodicSlot source  )  throw () [explicit, private]

Copy constructor made private to ensure that it will never be called.

The compiler should complain whenever this undefined constructor is called, implicitly or not.


Member Function Documentation

void PeriodicSlot::add ( ActiveObject newObject  )  throw ( SchedulingException )

Adds a new active object.

It will be registered in a slot, depending on its scheduling policy.

Note:
An object can be registered multiple times, even in the same periodic slot.
Exceptions:
SchedulingException if the operation failed.

Definition at line 58 of file OSDLPeriodicSlot.cc.

References OSDL::Engine::relaxed, and OSDL::Engine::strict.

void PeriodicSlot::remove ( ActiveObject object  )  throw ( SchedulingException )

Removes entirely an active object, possibly registered multiple time, from its slot.

Exceptions:
SchedulingException if the object was not found in any sub-slot of the slot.

Definition at line 93 of file OSDLPeriodicSlot.cc.

void PeriodicSlot::onNextTick ( Events::SimulationTick  newTick  )  throw ()

Activates all objects registered in the slot corresponding on this new tick.

Note:
The simulation tick is specified so that it can be propagated to active objects. No blocking checking is performed at the level of the periodic slot : it is assumed that no tick is skipped.

Definition at line 111 of file OSDLPeriodicSlot.cc.

References OSDL::Video::Pixels::toString().

void PeriodicSlot::onSimulationSkipped ( Events::SimulationTick  skipped  )  throw ( SchedulingException )

Notices all relevant objects that specified simulation tick has to be skipped.

Called by the scheduler whenever a simulation tick has to be skipped.

Exceptions:
SchedulingException if an object is unable to overcome a simulation skip (reserve it to special uncommon fatal cases, since skips may happen at any time on most computers).
Note:
Objects can have this method called multiple times for only one skipped simulation step, if they were to be scheduled multiple times during the skipped simulation tick (ex : an object both registered as programmed and periodic).

Definition at line 169 of file OSDLPeriodicSlot.cc.

Period PeriodicSlot::getPeriod (  )  throw ()

Returns the period this slot is in charge of.

Definition at line 190 of file OSDLPeriodicSlot.cc.

References _period.

const string PeriodicSlot::toString ( Ceylan::VerbosityLevels  level = Ceylan::high  )  const throw ()

Returns an user-friendly description of the state of this object.

Parameters:
level the requested verbosity level.
Note:
Text output format is determined from overall settings.

Periodic slots do not really implement the Ceylan::TextDisplayable interface, since the signature of the toString would require it is virtual, whereas this object is designed so that it has no virtual member, hence no virtual table overhead.

See also:
Ceylan::TextDisplayable

Definition at line 198 of file OSDLPeriodicSlot.cc.

References OSDL::Video::Pixels::toString().

Period PeriodicSlot::getSubSlotForSimulationTick ( Events::SimulationTick  tick  )  const throw () [protected]

Returns the sub-slot number corresponding to specified simulation tick.

Parameters:
tick the simulation tick to be translated into a sub-slot number for this periodic slot.

Definition at line 248 of file OSDLPeriodicSlot.cc.

void PeriodicSlot::addInSlot ( ActiveObject newObject,
Events::Period  targetSlot 
) throw () [protected]

Adds explicitly in specified slot the active object.

Definition at line 257 of file OSDLPeriodicSlot.cc.

bool PeriodicSlot::removeFromSlot ( ActiveObject object,
Events::Period  targetSlot 
) throw ( SchedulingException) [protected]

Removes from specified slot all subscriptions of the active object, and updates the slot weight.

Returns:
false if and only if object was not in slot.

Definition at line 270 of file OSDLPeriodicSlot.cc.

Period PeriodicSlot::getLeastBusySlot (  )  const throw () [protected]

Returns the first slot whose total object weights is minimal for this periodic slot.

Note:
the returned period can index a slot whose list pointer is null, since in all cases where all weights are null, the first slot, potentially with no list created, is returned.

Definition at line 309 of file OSDLPeriodicSlot.cc.

References _period, and _slotWeights.

void PeriodicSlot::activateAllObjectsInSubSlot ( Events::Period  subSlot,
Events::SimulationTick  currentTime 
) throw () [protected]

Activates in turn all active objects registered in the specified slot, from the first object ever registered to the last, if they had not been activated before.

Each of them is given the specified simulation time.

Parameters:
subSlot the sub-slot corresponding to this simulation tick for this periodicity. For example, for a periodicity of 7 simulation ticks, the selected sub-slot could be (current simulation tick) % 7.
currentTime the simulation time which should be given to activated objects.

Definition at line 329 of file OSDLPeriodicSlot.cc.

PeriodicSlot& OSDL::Engine::PeriodicSlot::operator= ( const PeriodicSlot source  )  throw () [private]

Assignment operator made private to ensure that it will never be called.

The compiler should complain whenever this undefined operator is called, implicitly or not.


Member Data Documentation

Events::Period OSDL::Engine::PeriodicSlot::_period [protected]

Stores the periodicity, expressed in simulation steps, of this slot.

Definition at line 250 of file OSDLPeriodicSlot.h.

Referenced by getLeastBusySlot(), getPeriod(), and ~PeriodicSlot().

Events::Period OSDL::Engine::PeriodicSlot::_currentSlot [protected]

Records the slot corresponding to current simulation step.

Definition at line 254 of file OSDLPeriodicSlot.h.

ListOfActiveObjects** OSDL::Engine::PeriodicSlot::_slots [protected]

This is an array of pointers to lists : ListOfActiveObjects * _slots[].

The pointed array has as many elements (slots) as constructor-specified periodicity.

Definition at line 265 of file OSDLPeriodicSlot.h.

Referenced by ~PeriodicSlot().

Weight* OSDL::Engine::PeriodicSlot::_slotWeights [protected]

Records the weights of all active objects registered in a slot.

Definition at line 273 of file OSDLPeriodicSlot.h.

Referenced by getLeastBusySlot(), and ~PeriodicSlot().


The documentation for this class was generated from the following files:
Generated on Fri Mar 30 14:47:25 2007 for OSDL by  doxygen 1.5.1