mirror of
https://github.com/dingusdev/dingusppc.git
synced 2025-01-23 06:31:28 +00:00
timermanager: support for timers that expire immediately.
This commit is contained in:
parent
c3f2c9e84c
commit
f814822ca3
@ -54,6 +54,27 @@ uint32_t TimerManager::add_oneshot_timer(uint64_t timeout, timer_cb cb)
|
|||||||
return ti->id;
|
return ti->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t TimerManager::add_immediate_timer(timer_cb cb) {
|
||||||
|
TimerInfo* ti = new TimerInfo;
|
||||||
|
|
||||||
|
ti->id = ++this->id;
|
||||||
|
ti->timeout_ns = this->get_time_now() + 10;
|
||||||
|
ti->interval_ns = 0;
|
||||||
|
ti->cb = cb;
|
||||||
|
|
||||||
|
std::shared_ptr<TimerInfo> timer_desc(ti);
|
||||||
|
|
||||||
|
// add new timer to the timer queue
|
||||||
|
this->timer_queue.push(timer_desc);
|
||||||
|
|
||||||
|
// notify listeners about changes in the timer queue
|
||||||
|
if (!this->cb_active) {
|
||||||
|
this->notify_timer_changes();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ti->id;
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t TimerManager::add_cyclic_timer(uint64_t interval, uint64_t delay, timer_cb cb)
|
uint32_t TimerManager::add_cyclic_timer(uint64_t interval, uint64_t delay, timer_cb cb)
|
||||||
{
|
{
|
||||||
if (!interval || interval <= MIN_TIMEOUT_NS) {
|
if (!interval || interval <= MIN_TIMEOUT_NS) {
|
||||||
|
@ -103,6 +103,7 @@ public:
|
|||||||
|
|
||||||
// creating and cancelling timers
|
// creating and cancelling timers
|
||||||
uint32_t add_oneshot_timer(uint64_t timeout, timer_cb cb);
|
uint32_t add_oneshot_timer(uint64_t timeout, timer_cb cb);
|
||||||
|
uint32_t add_immediate_timer(timer_cb cb);
|
||||||
uint32_t add_cyclic_timer(uint64_t interval, timer_cb cb);
|
uint32_t add_cyclic_timer(uint64_t interval, timer_cb cb);
|
||||||
uint32_t add_cyclic_timer(uint64_t interval, uint64_t delay, timer_cb cb);
|
uint32_t add_cyclic_timer(uint64_t interval, uint64_t delay, timer_cb cb);
|
||||||
void cancel_timer(uint32_t id);
|
void cancel_timer(uint32_t id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user