1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 16:18:12 +00:00

Kernel: Add timeout support to Thread::wait_on

This change plumbs a new optional timeout option to wait_on.
The timeout is enabled by enqueing a timer on the timer queue
while we are waiting. We can then see if we were woken up or
timed out by checking if we are still on the wait queue or not.
This commit is contained in:
Brian Gianforcaro 2020-04-26 02:32:37 -07:00 committed by Andreas Kling
parent 1d68837456
commit faf15e3721
3 changed files with 23 additions and 5 deletions

View file

@ -65,7 +65,8 @@ void Lock::lock(Mode mode)
m_lock.store(false, AK::memory_order_release);
return;
}
Thread::current->wait_on(m_queue, &m_lock, m_holder, m_name);
timeval* timeout = nullptr;
Thread::current->wait_on(m_queue, timeout, &m_lock, m_holder, m_name);
}
}
}