mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-30 05:08:56 +00:00
Kernel: Remove memory allocations from the new Blocker API
This commit is contained in:
committed by
Andreas Kling
parent
99c5377653
commit
cd76b691fb
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user