mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-01 06:07:59 +00:00
Kernel: Expose timers via a TimerId type
The public consumers of the timer API shouldn't need to know the how timer id's are tracked internally. Expose a typedef instead to allow the internal implementation to be protected from potential churn in the future. It's also just good API design.
This commit is contained in:
committed by
Andreas Kling
parent
13c122b8b2
commit
eeb5318c25
@@ -47,7 +47,7 @@ TimerQueue::TimerQueue()
|
||||
m_ticks_per_second = TimeManagement::the().ticks_per_second();
|
||||
}
|
||||
|
||||
u64 TimerQueue::add_timer(NonnullOwnPtr<Timer>&& timer)
|
||||
TimerId TimerQueue::add_timer(NonnullOwnPtr<Timer>&& timer)
|
||||
{
|
||||
ASSERT(timer->expires >= g_uptime);
|
||||
|
||||
@@ -64,7 +64,7 @@ u64 TimerQueue::add_timer(NonnullOwnPtr<Timer>&& timer)
|
||||
return m_timer_id_count;
|
||||
}
|
||||
|
||||
u64 TimerQueue::add_timer(timeval& deadline, Function<void()>&& callback)
|
||||
TimerId TimerQueue::add_timer(timeval& deadline, Function<void()>&& callback)
|
||||
{
|
||||
NonnullOwnPtr timer = make<Timer>();
|
||||
timer->expires = g_uptime + seconds_to_ticks(deadline.tv_sec) + microseconds_to_ticks(deadline.tv_usec);
|
||||
@@ -72,7 +72,7 @@ u64 TimerQueue::add_timer(timeval& deadline, Function<void()>&& callback)
|
||||
return add_timer(move(timer));
|
||||
}
|
||||
|
||||
bool TimerQueue::cancel_timer(u64 id)
|
||||
bool TimerQueue::cancel_timer(TimerId id)
|
||||
{
|
||||
auto it = m_timer_queue.find([id](auto& timer) { return timer->id == id; });
|
||||
if (it.is_end())
|
||||
|
||||
Reference in New Issue
Block a user