mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-29 16:21:29 +00:00
Kernel: Add WaitQueue::wait_forever and it use it for all infinite waits.
In preparation for marking BlockingResult [[nodiscard]], there are a few places that perform infinite waits, which we never observe the result of the wait. Instead of suppressing them, add an alternate function which returns void when performing and infinite wait.
This commit is contained in:
parent
4ac286903d
commit
ddd79fe2cf
Notes:
sideshowbarker
2024-07-18 22:18:29 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/ddd79fe2cfa Pull-request: https://github.com/SerenityOS/serenity/pull/5352
|
@ -239,7 +239,7 @@ void SB16::handle_irq(const RegisterState&)
|
|||
|
||||
void SB16::wait_for_irq()
|
||||
{
|
||||
m_irq_queue.wait_on({}, "SB16");
|
||||
m_irq_queue.wait_forever("SB16");
|
||||
disable_irq();
|
||||
}
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ KResultOr<NonnullRefPtr<FileDescription>> FIFO::open_direction_blocking(FIFO::Di
|
|||
|
||||
if (m_writers == 0) {
|
||||
locker.unlock();
|
||||
m_write_open_queue.wait_on({}, "FIFO");
|
||||
m_write_open_queue.wait_forever("FIFO");
|
||||
locker.lock();
|
||||
}
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ KResultOr<NonnullRefPtr<FileDescription>> FIFO::open_direction_blocking(FIFO::Di
|
|||
|
||||
if (m_readers == 0) {
|
||||
locker.unlock();
|
||||
m_read_open_queue.wait_on({}, "FIFO");
|
||||
m_read_open_queue.wait_forever("FIFO");
|
||||
locker.lock();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ void Lock::lock(Mode mode)
|
|||
}
|
||||
m_lock.store(false, AK::memory_order_release);
|
||||
dbgln_if(LOCK_TRACE_DEBUG, "Lock::lock @ {} ({}) waiting...", this, m_name);
|
||||
m_queue.wait_on({}, m_name);
|
||||
m_queue.wait_forever(m_name);
|
||||
dbgln_if(LOCK_TRACE_DEBUG, "Lock::lock @ {} ({}) waited", this, m_name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -444,7 +444,7 @@ void E1000NetworkAdapter::send_raw(ReadonlyBytes payload)
|
|||
sti();
|
||||
break;
|
||||
}
|
||||
m_wait_queue.wait_on({}, "E1000NetworkAdapter");
|
||||
m_wait_queue.wait_forever("E1000NetworkAdapter");
|
||||
}
|
||||
#if E1000_DEBUG
|
||||
dbgln("E1000: Sent packet, status is now {:#02x}!", (u8)descriptor.status);
|
||||
|
|
|
@ -392,7 +392,7 @@ void NE2000NetworkAdapter::send_raw(ReadonlyBytes payload)
|
|||
}
|
||||
|
||||
while (in8(REG_RW_COMMAND) & BIT_COMMAND_TXP)
|
||||
m_wait_queue.wait_on({}, "NE2000NetworkAdapter");
|
||||
m_wait_queue.wait_forever("NE2000NetworkAdapter");
|
||||
|
||||
disable_irq();
|
||||
size_t packet_size = payload.size();
|
||||
|
|
|
@ -106,7 +106,7 @@ void NetworkTask_main(void*)
|
|||
for (;;) {
|
||||
size_t packet_size = dequeue_packet(buffer, buffer_size, packet_timestamp);
|
||||
if (!packet_size) {
|
||||
packet_wait_queue.wait_on({}, "NetworkTask");
|
||||
packet_wait_queue.wait_forever("NetworkTask");
|
||||
continue;
|
||||
}
|
||||
if (packet_size < sizeof(EthernetFrameHeader)) {
|
||||
|
|
|
@ -91,7 +91,7 @@ void KernelRng::wait_for_entropy()
|
|||
ScopedSpinLock lock(get_lock());
|
||||
if (!resource().is_ready()) {
|
||||
dbgln("Entropy starvation...");
|
||||
m_seed_queue.wait_on({}, "KernelRng");
|
||||
m_seed_queue.wait_forever("KernelRng");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ void FinalizerTask::spawn()
|
|||
finalizer_thread, "FinalizerTask", [](void*) {
|
||||
Thread::current()->set_priority(THREAD_PRIORITY_LOW);
|
||||
for (;;) {
|
||||
g_finalizer_wait_queue->wait_on({}, "FinalizerTask");
|
||||
g_finalizer_wait_queue->wait_forever("FinalizerTask");
|
||||
|
||||
if (g_finalizer_has_work.exchange(false, AK::MemoryOrder::memory_order_acq_rel) == true)
|
||||
Thread::finalize_dying_threads();
|
||||
|
|
|
@ -50,6 +50,12 @@ public:
|
|||
return Thread::current()->block<Thread::QueueBlocker>(timeout, *this, forward<Args>(args)...);
|
||||
}
|
||||
|
||||
template<class... Args>
|
||||
void wait_forever(Args&&... args)
|
||||
{
|
||||
(void)Thread::current()->block<Thread::QueueBlocker>({}, *this, forward<Args>(args)...);
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual bool should_add_blocker(Thread::Blocker& b, void* data) override;
|
||||
|
||||
|
|
Loading…
Reference in a new issue