SST 16.1.0
Structural Simulation Toolkit
SST::Clock Class Reference

A Clock class. More...

#include <clock.h>

Inheritance diagram for SST::Clock:
SST::Action SST::Activity SST::Core::MemPoolItem SST::Core::Serialization::serializable SST::Core::Serialization::serializable_base

Data Structures

class  HandlerBase
 Base classes for clock handlers. More...

Public Types

template<typename classT, auto funcT, typename dataT = void>
using Handler = SSTHandler<bool, Cycle_t, classT, dataT, funcT, HandlerBase>
 Used to create handlers for clock.
template<typename classT, auto funcT, typename dataT = void>
using Handler2 = SSTHandler<bool, Cycle_t, classT, dataT, funcT, HandlerBase>
 Handler2 version which is now the same as Handler and is provided for backward compatibility until SST 17.

Public Member Functions

 Clock (TimeConverter period, int priority=CLOCKPRIORITY)
 Create a new clock with a specified period.
void schedule ()
 Activates this clock object, by inserting into the simulation's timeVortex for future execution.
Cycle_t getNextCycle ()
 Return the time of the next clock tick.
void updateCurrentCycle ()
 Update current cycle count - needed at simulation end if clock has run ahead of simulation end and to return correct cycle count in getNextCycle() for clocks that are currently not scheduled.
void registerHandler (Clock::HandlerBase *handler)
 Add a handler to be called on this clock's tick.
bool unregisterHandler (Clock::HandlerBase *handler, bool &empty)
 Remove a handler from the list of handlers to be called on the clock tick.
void registerHandler_restart (Clock::HandlerBase *handler)
 Add a handler to this Clock object during restart.
bool isHandlerRegistered (Clock::HandlerBase *handler)
 Checks to see if a handler is registered with this clock.
void registerGroup (Group *group)
 Register a group with this Clock object.
void activateGroup (Group *group)
 Activates a group that is inactive.
std::string toString () const override
 Get a string represenation of the event.
TimeConverter getPeriod ()
 Get the period of the clock as a TimeConverter.
Public Member Functions inherited from SST::Action
bool isEvent () const override final
bool isAction () const override final
Public Member Functions inherited from SST::Activity
void setDeliveryTime (SimTime_t time)
 Set the time for which this Activity should be delivered.
SimTime_t getDeliveryTime () const
 Return the time at which this Activity will be delivered.
int getPriority () const
 Return the Priority of this Activity.
void setOrderTag (uint32_t tag)
 Sets the order tag.
uint32_t getOrderTag () const
 Return the order tag associated with this activity.
uint64_t getQueueOrder () const
 Returns the queue order associated with this activity.
void setQueueOrder (uint64_t order)
 Set a new Queue order.
virtual void copyAllDeliveryInfo (const Activity *act)
Public Member Functions inherited from SST::Core::MemPoolItem
void * operator new (std::size_t size) noexcept
 Allocates memory from a memory pool for a new Activity.
void operator delete (void *ptr)
 Returns memory for this Activity to the appropriate memory pool.
virtual void print (const std::string &header, Output &out) const
Public Member Functions inherited from SST::Core::Serialization::serializable_base
virtual const char * cls_name () const =0
virtual uint32_t cls_id () const =0
virtual std::string serialization_name () const =0

Friends

class BaseComponent
class Component
class Simulation

Additional Inherited Members

Static Public Attributes inherited from SST::Core::Serialization::serializable
static constexpr uint32_t NullClsId = std::numeric_limits<uint32_t>::max()
Static Public Attributes inherited from SST::Core::Serialization::serializable_base
static constexpr uint32_t NullClsId = std::numeric_limits<uint32_t>::max()
Protected Types inherited from SST::Core::Serialization::serializable_base
enum  cxn_flag_t { ConstructorFlag }
Protected Member Functions inherited from SST::Action
void endSimulation ()
 Called to signal to the Simulation object to end the simulation.
void endSimulation (SimTime_t end)
 Called to signal to the Simulation object to end the simulation.
Protected Member Functions inherited from SST::Activity
void setPriority (uint64_t priority)
 Set the priority of the Activity.
std::string getDeliveryTimeInfo () const
 Gets the delivery time info as a string.
 ImplementVirtualSerializable (SST::Activity)
Static Protected Member Functions inherited from SST::Core::Serialization::serializable_base
static void serializable_abort (uint32_t line, const char *file, const char *func, const char *obj)

Detailed Description

A Clock class.

Calls callback functions (handlers) on a specified period

Member Typedef Documentation

◆ Handler

template<typename classT, auto funcT, typename dataT = void>
using SST::Clock::Handler = SSTHandler<bool, Cycle_t, classT, dataT, funcT, HandlerBase>

Used to create handlers for clock.

The callback function is expected to be in the form of:

bool func(Cycle_t cycle)

In which case, the class is created with:

new Clock::Handler<classname, &classname::function_name>(this)

Or, to add static data, the callback function is:

bool func(Cycle_t cycle, dataT data)

and the class is created with:

new Clock::Handler<classname, &classname::function_name, dataT>(this, data)

In both cases, the boolean that's returned indicates whether the handler should be removed from the list or not. On return of true, the handler will be removed. On return of false, the handler will be left in the clock list.

◆ Handler2

template<typename classT, auto funcT, typename dataT = void>
using SST::Clock::Handler2 = SSTHandler<bool, Cycle_t, classT, dataT, funcT, HandlerBase>

Handler2 version which is now the same as Handler and is provided for backward compatibility until SST 17.

Deprecated
The name Handler2 has been deprecated and will be removed in SST 17. Please rename Handler2 to Handler.

Constructor & Destructor Documentation

◆ Clock()

SST::Clock::Clock ( TimeConverter period,
int priority = CLOCKPRIORITY )

Create a new clock with a specified period.

References Clock(), and SST::Activity::setPriority().

Referenced by Clock().

Member Function Documentation

◆ activateGroup()

void SST::Clock::activateGroup ( Clock::Group * group)

Activates a group that is inactive.

If group is already active, nothing is done. There is no need for a deactivateGroup() call as deactivation is only done based on return value during execute()

References schedule().

◆ getNextCycle()

Cycle_t SST::Clock::getNextCycle ( )

Return the time of the next clock tick.

References updateCurrentCycle().

◆ getPeriod()

TimeConverter SST::Clock::getPeriod ( )
inline

Get the period of the clock as a TimeConverter.

References getPeriod().

Referenced by getPeriod().

◆ registerHandler()

void SST::Clock::registerHandler ( Clock::HandlerBase * handler)

◆ registerHandler_restart()

void SST::Clock::registerHandler_restart ( Clock::HandlerBase * handler)

Add a handler to this Clock object during restart.

References SST::Clock::HandlerBase::isActive(), and schedule().

Referenced by SST::Simulation::registerClock_restart().

◆ schedule()

void SST::Clock::schedule ( )

Activates this clock object, by inserting into the simulation's timeVortex for future execution.

References SST::Activity::getPriority().

Referenced by activateGroup(), registerHandler(), and registerHandler_restart().

◆ toString()

std::string SST::Clock::toString ( ) const
overridevirtual

Get a string represenation of the event.

The default version will just use the name of the class, retrieved through the cls_name() function inherited from the serialzable class, which will return the name of the last class to call one of the serialization macros (ImplementSerializable(), ImplementVirtualSerializable(), or NotSerializable()). Subclasses can override this function if they want to add additional information.

Reimplemented from SST::Activity.

References SST::Activity::getDeliveryTime(), and SST::Activity::getPriority().

◆ unregisterHandler()

bool SST::Clock::unregisterHandler ( Clock::HandlerBase * handler,
bool & empty )

Remove a handler from the list of handlers to be called on the clock tick.

References SST::Clock::HandlerBase::isActive().

◆ updateCurrentCycle()

void SST::Clock::updateCurrentCycle ( )

Update current cycle count - needed at simulation end if clock has run ahead of simulation end and to return correct cycle count in getNextCycle() for clocks that are currently not scheduled.

Referenced by getNextCycle().


The documentation for this class was generated from the following files:
  • src/sst/core/clock.h
  • src/sst/core/clock.cc