diff --git a/Kernel/TimerQueue.cpp b/Kernel/TimerQueue.cpp index 1f301c63b0..8bf69f302e 100644 --- a/Kernel/TimerQueue.cpp +++ b/Kernel/TimerQueue.cpp @@ -115,81 +115,6 @@ void TimerQueue::add_timer_locked(NonnullRefPtr timer) } } -TimerId TimerQueue::add_timer(clockid_t clock_id, const Time& deadline, Function&& 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 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(); diff --git a/Kernel/TimerQueue.h b/Kernel/TimerQueue.h index 28bf22bf8a..d243609cb9 100644 --- a/Kernel/TimerQueue.h +++ b/Kernel/TimerQueue.h @@ -89,13 +89,7 @@ public: TimerId add_timer(NonnullRefPtr&&); bool add_timer_without_id(NonnullRefPtr, clockid_t, const Time&, Function&&); - TimerId add_timer(clockid_t, const Time& timeout, Function&& callback); - bool cancel_timer(TimerId id); bool cancel_timer(Timer& timer, bool* was_in_use = nullptr); - bool cancel_timer(NonnullRefPtr&& timer) - { - return cancel_timer(*move(timer)); - } void fire(); private: