1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 04:38:11 +00:00

Kernel: Remove memory allocations from the new Blocker API

This commit is contained in:
Robin Burchell 2019-07-19 10:12:50 +02:00 committed by Andreas Kling
parent 99c5377653
commit cd76b691fb
6 changed files with 27 additions and 27 deletions

View file

@ -110,9 +110,7 @@ void Thread::unblock()
void Thread::block_until(const char* state_string, Function<bool()>&& condition)
{
m_blocker = make<ConditionBlocker>(state_string, condition);
block_helper();
Scheduler::yield();
block<ConditionBlocker>(state_string, condition);
}
void Thread::block_helper()
@ -126,17 +124,11 @@ void Thread::block_helper()
process().big_lock().lock();
}
void Thread::block(Blocker& blocker)
{
m_blocker = &blocker;
block_helper();
}
u64 Thread::sleep(u32 ticks)
{
ASSERT(state() == Thread::Running);
u64 wakeup_time = g_uptime + ticks;
current->block(*new Thread::SleepBlocker(wakeup_time));
current->block<Thread::SleepBlocker>(wakeup_time);
return wakeup_time;
}
@ -532,7 +524,7 @@ KResult Thread::wait_for_connect(FileDescription& description)
auto& socket = *description.socket();
if (socket.is_connected())
return KSuccess;
block(*new Thread::ConnectBlocker(description));
block<Thread::ConnectBlocker>(description);
Scheduler::yield();
if (!socket.is_connected())
return KResult(-ECONNREFUSED);