Browse Source

Kernel: Remove a bunch of unused TimerQueue functions

Andreas Kling 3 years ago
parent
commit
e550d53c0f
2 changed files with 0 additions and 81 deletions
  1. 0 75
      Kernel/TimerQueue.cpp
  2. 0 6
      Kernel/TimerQueue.h

+ 0 - 75
Kernel/TimerQueue.cpp

@@ -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();

+ 0 - 6
Kernel/TimerQueue.h

@@ -89,13 +89,7 @@ public:
 
     TimerId add_timer(NonnullRefPtr<Timer>&&);
     bool add_timer_without_id(NonnullRefPtr<Timer>, clockid_t, const Time&, Function<void()>&&);
-    TimerId add_timer(clockid_t, const Time& timeout, Function<void()>&& callback);
-    bool cancel_timer(TimerId id);
     bool cancel_timer(Timer& timer, bool* was_in_use = nullptr);
-    bool cancel_timer(NonnullRefPtr<Timer>&& timer)
-    {
-        return cancel_timer(*move(timer));
-    }
     void fire();
 
 private: