OSDL::Engine::PeriodicSlot Class Reference

Records informations about a periodic slot. More...

#include <OSDLPeriodicSlot.h>

Collaboration diagram for OSDL::Engine::PeriodicSlot:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 PeriodicSlot (Events::Period periodicity)
 Creates a scheduler slot for given non-null periodicity, expressed in simulation ticks.
 ~PeriodicSlot () throw ()
 Non-virtual destructor.
Events::Period add (PeriodicalActiveObject &newObject)
 Adds a new periodical active object to that slot.
void removeFromSubslot (PeriodicalActiveObject &object)
 Removes specified periodical object from specified sub-slot, and updates the slot weight.
bool onNextTick (Events::SimulationTick newTick)
 Activates all objects registered in the sub-slot corresponding to this new tick.
void onSimulationSkipped (Events::SimulationTick skipped)
 Notifies all relevant objects that specified simulation tick had to be skipped.
Events::Period getPeriod () const
 Returns the period this slot is in charge of.
bool isEmpty () const
 Returns true iff the slot is fully empty,, i.e.
const std::string toString (Ceylan::VerbosityLevels level=Ceylan::high) const
 Returns an user-friendly description of the state of this object.

Protected Member Functions

Events::Period getSubSlotForSimulationTick (Events::SimulationTick tick) const
 Returns the sub-slot number corresponding to specified simulation tick.
Events::Period getLeastBusySubSlot () const
 Returns the first sub-slot whose total object weight is minimal for this periodic slot.
void addInSubSlot (PeriodicalActiveObject &newObject, Events::Period targetSubSlot)
 Adds explicitly in specified sub-slot the active object.
bool activateAllObjectsInSubSlot (Events::Period subSlot, Events::SimulationTick currentTime)
 Activates in turn all active objects registered in the specified sub-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 ticks, of this slot.
Events::Period _currentSubSlot
 Records the slot corresponding to current simulation tick.
ListOfPeriodicalActiveObjects ** _subslots
 This is an array of pointers to lists: ListOfPeriodicalActiveObjects * _subslots[].
Weight_subslotWeights
 Records the weights of all active objects registered in a slot.

Private Member Functions

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

Detailed Description

Records informations about a periodic slot.

Each of these periodic slots is internally divided into as many sub-slots as the length of that slot period.

Each registered periodical active object will then be listed in exactly one sub-slot.

For example, when a PeriodicSlot will be created to manage all objects relying on a periodicity of 7 simulation ticks, that slot will have internally an array 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 tick, all objects put in corresponding sub-slot will be activated. On the next tick, 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 at 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 94 of file OSDLPeriodicSlot.h.


Constructor & Destructor Documentation

OSDL::Engine::PeriodicSlot::PeriodicSlot ( Events::Period  periodicity  )  [explicit]

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

Parameters:
periodicity the chosen periodicity.
PeriodicSlot::~PeriodicSlot (  )  throw ()

Non-virtual destructor.

Definition at line 67 of file OSDLPeriodicSlot.cc.

References _period, _subslots, _subslotWeights, and OSDL::Video::Pixels::toString().

OSDL::Engine::PeriodicSlot::PeriodicSlot ( const PeriodicSlot source  )  [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

bool OSDL::Engine::PeriodicSlot::activateAllObjectsInSubSlot ( Events::Period  subSlot,
Events::SimulationTick  currentTime 
) [protected]

Activates in turn all active objects registered in the specified sub-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.
Returns:
true iff this periodic sub-slot should be kept.
Period PeriodicSlot::add ( PeriodicalActiveObject newObject  ) 

Adds a new periodical active object to that slot.

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

The slot weight will be updated.

Returns:
the sub-slot this object was registered in.
Exceptions:
SchedulingException if the operation failed.

Definition at line 112 of file OSDLPeriodicSlot.cc.

References _currentSubSlot, _period, addInSubSlot(), getLeastBusySubSlot(), OSDL::Engine::ActiveObject::getPolicy(), OSDL::Engine::relaxed, and OSDL::Engine::strict.

Referenced by OSDL::Engine::Scheduler::registerPeriodicalObject().

void OSDL::Engine::PeriodicSlot::addInSubSlot ( PeriodicalActiveObject newObject,
Events::Period  targetSubSlot 
) [protected]

Adds explicitly in specified sub-slot the active object.

Referenced by add().

Period PeriodicSlot::getLeastBusySubSlot (  )  const [protected]

Returns the first sub-slot whose total object weight is minimal for this periodic slot.

Note:
the returned period number 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 418 of file OSDLPeriodicSlot.cc.

References _period, and _subslotWeights.

Referenced by add().

Period PeriodicSlot::getPeriod (  )  const

Returns the period this slot is in charge of.

Definition at line 313 of file OSDLPeriodicSlot.cc.

References _period.

Events::Period OSDL::Engine::PeriodicSlot::getSubSlotForSimulationTick ( Events::SimulationTick  tick  )  const [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.
bool PeriodicSlot::isEmpty (  )  const

Returns true iff the slot is fully empty,, i.e.

none of its sub-slots contains any object.

Definition at line 322 of file OSDLPeriodicSlot.cc.

References _period, and _subslots.

bool OSDL::Engine::PeriodicSlot::onNextTick ( Events::SimulationTick  newTick  ) 

Activates all objects registered in the sub-slot corresponding to this new tick.

Note:
The simulation tick is specified so that it can be propagated to active objects.

No blocking checking that no simulation tick was skipped is performed at the level of the periodic slot.

Returns:
true iff this periodic slot should be kept.
void OSDL::Engine::PeriodicSlot::onSimulationSkipped ( Events::SimulationTick  skipped  ) 

Notifies all relevant objects that specified simulation tick had 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 tick, if they were to be scheduled multiple times during the skipped simulation tick (ex: an object both registered as programmed and periodic).
PeriodicSlot& OSDL::Engine::PeriodicSlot::operator= ( const PeriodicSlot source  )  [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.

void PeriodicSlot::removeFromSubslot ( PeriodicalActiveObject object  ) 

Removes specified periodical object from specified sub-slot, and updates the slot weight.

Exceptions:
SchedulingException if the operation failed.

Definition at line 150 of file OSDLPeriodicSlot.cc.

References _subslots, _subslotWeights, OSDL::Video::Pixels::toString(), and toString().

Referenced by OSDL::Engine::Scheduler::unregisterPeriodicalObject().

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

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 340 of file OSDLPeriodicSlot.cc.

References _currentSubSlot, _period, _subslots, _subslotWeights, and OSDL::Video::Pixels::toString().

Referenced by removeFromSubslot().


Member Data Documentation

Records the slot corresponding to current simulation tick.

Definition at line 299 of file OSDLPeriodicSlot.h.

Referenced by add(), and toString().

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

Definition at line 294 of file OSDLPeriodicSlot.h.

Referenced by add(), getLeastBusySubSlot(), getPeriod(), isEmpty(), toString(), and ~PeriodicSlot().

This is an array of pointers to lists: ListOfPeriodicalActiveObjects * _subslots[].

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

Ex: for a period of 3, we have list #0, #1 and #2.

Definition at line 313 of file OSDLPeriodicSlot.h.

Referenced by isEmpty(), removeFromSubslot(), toString(), and ~PeriodicSlot().

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

Definition at line 322 of file OSDLPeriodicSlot.h.

Referenced by getLeastBusySubSlot(), removeFromSubslot(), toString(), and ~PeriodicSlot().


The documentation for this class was generated from the following files:
Generated on Mon Nov 29 14:05:33 2010 for OSDL by  doxygen 1.6.3