Skip to content

Commit 85fe22d

Browse files
committed
zephyr: work/kio: Timeout support for work
All hand-written work to directly schedule timeouts. Signed-off-by: David Brown <[email protected]>
1 parent 28b3465 commit 85fe22d

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

zephyr/src/kio.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ pub trait ContextExt {
143143
/// Indicate that the work should be scheduled when the given [`Queue`] has data available to
144144
/// recv, or the timeout occurs.
145145
fn add_queue<'a>(&'a mut self, queue: &'a Queue, timeout: impl Into<Timeout>);
146+
147+
/// Indicate that the work should just be scheduled after the given timeout.
148+
///
149+
/// Note that this only works if none of the other wake methods are called, as those also set
150+
/// the timeout.
151+
fn add_timeout(&mut self, timeout: impl Into<Timeout>);
146152
}
147153

148154
/// Implementation of ContextExt for the Rust [`Context`] type.
@@ -164,4 +170,9 @@ impl<'b> ContextExt for Context<'b> {
164170
info.add_queue(queue);
165171
info.timeout = timeout.into();
166172
}
173+
174+
fn add_timeout(&mut self, timeout: impl Into<Timeout>) {
175+
let info = unsafe { WakeInfo::from_context(self) };
176+
info.timeout = timeout.into();
177+
}
167178
}

zephyr/src/work.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,12 @@ impl Signal {
464464
}
465465
}
466466

467+
impl Default for Signal {
468+
fn default() -> Self {
469+
Signal::new().unwrap()
470+
}
471+
}
472+
467473
/// The Future for Signal::wait_async.
468474
struct SignalWait<'a> {
469475
/// The signal we are waiting on.

0 commit comments

Comments
 (0)