mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 19:04:58 +00:00
Kernel: Consolidate timeout logic
Allow passing in an optional timeout to Thread::block and move the timeout check out of Thread::Blocker. This way all Blockers implicitly support timeouts and don't need to implement it themselves. Do however allow them to override timeouts (e.g. for sockets).
This commit is contained in:
@@ -423,7 +423,7 @@ KResult Plan9FS::post_message(Message& message)
|
||||
|
||||
while (size > 0) {
|
||||
if (!description.can_write()) {
|
||||
if (Thread::current()->block<Thread::WriteBlocker>(description).was_interrupted())
|
||||
if (Thread::current()->block<Thread::WriteBlocker>(nullptr, description).was_interrupted())
|
||||
return KResult(-EINTR);
|
||||
}
|
||||
ssize_t nwritten = description.write(data, size);
|
||||
@@ -441,7 +441,7 @@ KResult Plan9FS::do_read(u8* data, size_t size)
|
||||
auto& description = file_description();
|
||||
while (size > 0) {
|
||||
if (!description.can_read()) {
|
||||
if (Thread::current()->block<Thread::ReadBlocker>(description).was_interrupted())
|
||||
if (Thread::current()->block<Thread::ReadBlocker>(nullptr, description).was_interrupted())
|
||||
return KResult(-EINTR);
|
||||
}
|
||||
ssize_t nread = description.read(data, size);
|
||||
@@ -524,7 +524,7 @@ KResult Plan9FS::wait_for_specific_message(u16 tag, Message& out_message)
|
||||
// Block until either:
|
||||
// * Someone else reads the message we're waiting for, and hands it to us;
|
||||
// * Or we become the one to read and dispatch messages.
|
||||
if (Thread::current()->block<Plan9FS::Blocker>(completion).was_interrupted()) {
|
||||
if (Thread::current()->block<Plan9FS::Blocker>(nullptr, completion).was_interrupted()) {
|
||||
LOCKER(m_lock);
|
||||
m_completions.remove(tag);
|
||||
return KResult(-EINTR);
|
||||
|
||||
Reference in New Issue
Block a user