TimerModule provides convenient interface of timer/alarm.
More...
#include <E_TimerModule.hpp>
|
| 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...
|
|
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
◆ addTimer()
UUID E::TimerModule::addTimer |
( |
std::any |
payload, |
|
|
Time |
timeAfter |
|
) |
| |
|
finalprotectedvirtual |
Request an alarm that rings after specified time.
- Parameters
-
payload | Metadata you needed. Can be null. |
timeAfter | Specify 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
-
key | Unique 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
-
payload | Metadata 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: