mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 23:09:08 +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:
parent
df52061cdb
commit
f4a5c9b6c2
Notes:
sideshowbarker
2024-07-19 04:21:12 +09:00
Author: https://github.com/tomuta
Commit: f4a5c9b6c2
Pull-request: https://github.com/SerenityOS/serenity/pull/2980
15 changed files with 60 additions and 77 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue