mirror of
https://github.com/hexagonal-sun/moss-kernel.git
synced 2025-12-23 22:47:55 -05:00
libkernel: waker_set: return whether a waker was woken
Make `wake_one()` return `true` indicating whether a waker was woken from the set, `false` otherwise.
This commit is contained in:
committed by
Ashwin Naren
parent
78440f292b
commit
ca787aa4c3
@@ -51,7 +51,9 @@ impl<S, C: CpuOps> CondVar<S, C> {
|
||||
|
||||
match updater(&mut inner.state) {
|
||||
WakeupType::None => (),
|
||||
WakeupType::One => inner.wakers.wake_one(),
|
||||
WakeupType::One => {
|
||||
inner.wakers.wake_one();
|
||||
}
|
||||
WakeupType::All => inner.wakers.wake_all(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,9 +54,14 @@ impl WakerSet {
|
||||
}
|
||||
|
||||
/// Wakes one waiting task, if any.
|
||||
pub fn wake_one(&mut self) {
|
||||
///
|
||||
/// Returns `true` if a waker was awoken, `false` otherwise.
|
||||
pub fn wake_one(&mut self) -> bool {
|
||||
if let Some((_, waker)) = self.waiters.pop_first() {
|
||||
waker.wake();
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user