1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-02 21:42:12 +00:00

Kernel: Remove a bunch of unused TimerQueue functions

This commit is contained in:
Andreas Kling 2021-09-07 18:22:34 +02:00
parent 905065f8c8
commit e550d53c0f
2 changed files with 0 additions and 81 deletions

View file

@ -115,81 +115,6 @@ void TimerQueue::add_timer_locked(NonnullRefPtr<Timer> timer)
}
}
TimerId TimerQueue::add_timer(clockid_t clock_id, const Time& deadline, Function<void()>&& callback)
{
auto expires = TimeManagement::the().current_time(clock_id);
expires = expires + deadline;
auto timer = new Timer();
VERIFY(timer);
timer->setup(clock_id, expires, move(callback));
return add_timer(adopt_ref(*timer));
}
bool TimerQueue::cancel_timer(TimerId id)
{
Timer* found_timer = nullptr;
Queue* timer_queue = nullptr;
SpinlockLocker lock(g_timerqueue_lock);
for (auto& timer : m_timer_queue_monotonic.list) {
if (timer.m_id == id) {
found_timer = &timer;
timer_queue = &m_timer_queue_monotonic;
break;
}
}
if (found_timer == nullptr) {
for (auto& timer : m_timer_queue_realtime.list) {
if (timer.m_id == id) {
found_timer = &timer;
timer_queue = &m_timer_queue_realtime;
break;
}
};
}
if (found_timer) {
VERIFY(timer_queue);
remove_timer_locked(*timer_queue, *found_timer);
return true;
}
// The timer may be executing right now, if it is then it should
// be in m_timers_executing. This is the case when the deferred
// call has been queued but not yet executed.
for (auto& timer : m_timers_executing) {
if (timer.m_id == id) {
found_timer = &timer;
break;
}
}
if (!found_timer)
return false;
// Keep a reference while we unlock
NonnullRefPtr<Timer> executing_timer(*found_timer);
lock.unlock();
if (!found_timer->set_cancelled()) {
// We cancelled it even though the deferred call has been queued already.
// We do not unref the timer here because the deferred call is still going
// too need it!
lock.lock();
VERIFY(m_timers_executing.contains(*found_timer));
m_timers_executing.remove(*found_timer);
return true;
}
// At this point the deferred call is queued and is being executed
// on another processor. We need to wait until it's complete!
while (!found_timer->is_callback_finished())
Processor::wait_check();
return true;
}
bool TimerQueue::cancel_timer(Timer& timer, bool* was_in_use)
{
bool in_use = timer.is_in_use();