mirror of
https://github.com/RGBCube/serenity
synced 2025-05-25 19:25:07 +00:00
Kernel: Consolidate timeout logic
Allow passing in an optional timeout to Thread::block and move the timeout check out of Thread::Blocker. This way all Blockers implicitly support timeouts and don't need to implement it themselves. Do however allow them to override timeouts (e.g. for sockets).
This commit is contained in:
parent
df52061cdb
commit
f4a5c9b6c2
15 changed files with 60 additions and 77 deletions
|
@ -209,7 +209,7 @@ u64 Thread::sleep(u64 ticks)
|
|||
{
|
||||
ASSERT(state() == Thread::Running);
|
||||
u64 wakeup_time = g_uptime + ticks;
|
||||
auto ret = Thread::current()->block<Thread::SleepBlocker>(wakeup_time);
|
||||
auto ret = Thread::current()->block<Thread::SleepBlocker>(nullptr, wakeup_time);
|
||||
if (wakeup_time > g_uptime) {
|
||||
ASSERT(ret.was_interrupted());
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ u64 Thread::sleep(u64 ticks)
|
|||
u64 Thread::sleep_until(u64 wakeup_time)
|
||||
{
|
||||
ASSERT(state() == Thread::Running);
|
||||
auto ret = Thread::current()->block<Thread::SleepBlocker>(wakeup_time);
|
||||
auto ret = Thread::current()->block<Thread::SleepBlocker>(nullptr, wakeup_time);
|
||||
if (wakeup_time > g_uptime)
|
||||
ASSERT(ret.was_interrupted());
|
||||
return wakeup_time;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue