KENSv3
KAIST Educational Network System
Protected Member Functions | Friends | List of all members
E::TimerModule Class Referenceabstract

TimerModule provides convenient interface of timer/alarm. More...

#include <E_TimerModule.hpp>

Inheritance diagram for E::TimerModule:
E::PWOSPFAssignment E::RIPAssignment E::TCPAssignment

Protected Member Functions

 TimerModule (std::string name, Host &host)
 
virtual std::string getTimerModuleName () final
 
virtual void timerCallback (std::any payload)=0
 This function is automatically when requested alarm is triggered. You must override this pure virtual function to use TimerModule. More...
 
virtual UUID addTimer (std::any payload, Time timeAfter) final
 Request an alarm that rings after specified time. More...
 
virtual void cancelTimer (UUID key) final
 Cancel the timer request. More...
 

Friends

class Host
 

Detailed Description

TimerModule provides convenient interface of timer/alarm.

Note
If you need custom Message handling, DO NOT USE THIS CLASS. i.e. you cannot use both Module and TimerModule
See also
Module

Member Function Documentation

◆ addTimer()

UUID E::TimerModule::addTimer ( std::any  payload,
Time  timeAfter 
)
finalprotectedvirtual

Request an alarm that rings after specified time.

Parameters
payloadMetadata you needed. Can be null.
timeAfterSpecify when the alarm will ring.
Returns
Unique ID that indicates the timer request.
Note
You cannot override this function.

◆ cancelTimer()

void E::TimerModule::cancelTimer ( UUID  key)
finalprotectedvirtual

Cancel the timer request.

Parameters
keyUnique ID that indicates the timer request.
Note
You cannot override this function. There is no Module::messageCancelled here, so be sure that you deallocated any resources you allocated for the timer.
See also
addTimer, Module::messageCancelled

◆ getTimerModuleName()

std::string E::TimerModule::getTimerModuleName ( )
finalprotectedvirtual
Returns
My name used in the registered Host.

◆ timerCallback()

virtual void E::TimerModule::timerCallback ( std::any  payload)
protectedpure virtual

This function is automatically when requested alarm is triggered. You must override this pure virtual function to use TimerModule.

Parameters
payloadMetadata that you specified via addTimer
Note
TimerModule does nothing for the payload. You may deallocate payload IF NEEDED.

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