mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 11:37:34 +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
|
@ -1,7 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <AK/CircularQueue.h>
|
||||
#include <Kernel/Alarm.h>
|
||||
#include <Kernel/Devices/CharacterDevice.h>
|
||||
#include <Kernel/IRQHandler.h>
|
||||
#include <Kernel/VM/PhysicalAddress.h>
|
||||
|
@ -9,18 +8,6 @@
|
|||
|
||||
class SB16;
|
||||
|
||||
class SB16InterruptAlarm final : public Alarm {
|
||||
public:
|
||||
SB16InterruptAlarm(SB16& device)
|
||||
: m_device(device)
|
||||
{
|
||||
}
|
||||
virtual bool is_ringing() const override;
|
||||
|
||||
private:
|
||||
SB16& m_device;
|
||||
};
|
||||
|
||||
class SB16 final : public IRQHandler
|
||||
, public CharacterDevice {
|
||||
public:
|
||||
|
@ -35,8 +22,6 @@ public:
|
|||
virtual ssize_t write(FileDescription&, const u8*, ssize_t) override;
|
||||
virtual bool can_write(FileDescription&) const override { return true; }
|
||||
|
||||
bool got_interrupt(Badge<SB16InterruptAlarm>) const { return m_interrupted; }
|
||||
|
||||
private:
|
||||
// ^IRQHandler
|
||||
virtual void handle_irq() override;
|
||||
|
@ -54,6 +39,4 @@ private:
|
|||
RefPtr<PhysicalPage> m_dma_buffer_page;
|
||||
bool m_interrupted { false };
|
||||
int m_major_version { 0 };
|
||||
|
||||
SB16InterruptAlarm m_interrupt_alarm;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue