Hiva::CreateWallTimer
Description
Creates a WallTimer.
Prototype
Hiva::WallTimer Hiva::CreateWallTimer(const Hiva::WallDuration &wallPeriod, const WallTimerCallback &wallCallback, const std::string &wallGroupName, const bool oneshot = false, const bool autostart = true)
Parameters
Parameter |
Input/Output |
Description |
||
|---|---|---|---|---|
wallPeriod |
Input |
Period for triggering the callback function. The value is of the standard Duration type for the framework. |
||
wallCallback |
Input |
Callback function after the timer expires. The type is WallTimerCallback. WallTimerEvent is as follows: using WallTimerCallback = std::function<void (const WallTimerEvent &)>;
|
||
wallGroupName |
Input |
Thread group created when OpenHiva::Init is invoked. For a deterministic group, the deterministic scheduling framework is used. For other groups, the OS scheduling framework is used. |
||
oneshot |
Input |
Mode flag.
|
||
autostart |
Input |
Start flag.
|
Returns
The handle of Hiva::WallTimer is returned. The start and stop operations can be performed based on this handle.
Usage
A process invokes this interface to create and run a timer.
- When creating a WallTimer, an application subscribes to a timer event. The timer name is generated in the format of application name + timer + sequence number to ensure uniqueness.
- The application sends the timer name and related information to the timer server through the topic communication mode of the server/client. After the time expires, the timer server publishes the topic, notifies the original application, and executes the user callback function.
Precautions
None