mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:17:45 +00:00
Kernel: Add Thread::block_until(Condition).
Replace the class-based snooze alarm mechanism with a per-thread callback. This makes it easy to block the current thread on an arbitrary condition: void SomeDevice::wait_for_irq() { m_interrupted = false; current->block_until([this] { return m_interrupted; }); } void SomeDevice::handle_irq() { m_interrupted = true; } Use this in the SB16 driver, and in NetworkTask :^)
This commit is contained in:
parent
e8d61bb8c0
commit
b2e502e533
8 changed files with 22 additions and 78 deletions
|
@ -49,7 +49,6 @@ static SB16* s_the;
|
|||
SB16::SB16()
|
||||
: IRQHandler(5)
|
||||
, CharacterDevice(42, 42) // ### ?
|
||||
, m_interrupt_alarm(*this)
|
||||
{
|
||||
s_the = this;
|
||||
initialize();
|
||||
|
@ -144,7 +143,7 @@ void SB16::wait_for_irq()
|
|||
#ifdef SB16_DEBUG
|
||||
kprintf("SB16: waiting for interrupt...\n");
|
||||
#endif
|
||||
current->snooze_until(m_interrupt_alarm);
|
||||
current->block_until([this] { return m_interrupted; });
|
||||
#ifdef SB16_DEBUG
|
||||
kprintf("SB16: got interrupt!\n");
|
||||
#endif
|
||||
|
@ -195,8 +194,3 @@ ssize_t SB16::write(FileDescription&, const u8* data, ssize_t length)
|
|||
wait_for_irq();
|
||||
return length;
|
||||
}
|
||||
|
||||
bool SB16InterruptAlarm::is_ringing() const
|
||||
{
|
||||
return m_device.got_interrupt({});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue