|
VLink
2.0.0
A high-performance communication middleware
|
MessageLoop-driven periodic or one-shot timer with priority support. 更多...
#include <atomic>#include <cstdint>#include <memory>#include "./functional.h"#include "./macros.h"类 | |
| class | vlink::Timer |
Periodic or one-shot timer that fires on an associated MessageLoop thread. 更多... | |
命名空间 | |
| vlink | |
MessageLoop-driven periodic or one-shot timer with priority support.
vlink::Timer dispatches its callback on a MessageLoop thread, so the callback runs serially with every other task posted to the same loop and no additional synchronisation is required inside the callback body.
Timer modes determined by loop_count:
| Mode | loop_count value | Behaviour |
|---|---|---|
| One-shot | 1 | Fires exactly once after one full interval |
| Counted | 2 ... INT_MAX | Fires the configured number of times |
| Repeating | kInfinite (-1) | Fires forever until stop() is called |
Key features:
kPriorityType message loops.interval_ms is 0 the internal interval clamps to kMinInterval (10000 ns = 10 us) to avoid pathological busy-spinning.call_once() helper posts a fire-and-forget one-shot without managing a Timer object.attach() (if not done at construction) -> start() -> repeated ticks -> stop() / restart() / destruction.