Commit bd6e2901 authored by Alice Ryhl's avatar Alice Ryhl Committed by Treehugger Robot
Browse files

FROMGIT: rust: sync: add `CondVar::wait_timeout`



Sleep on a condition variable with a timeout.

This is used by Rust Binder for process freezing. There, we want to
sleep until the freeze operation completes, but we want to be able to
abort the process freezing if it doesn't complete within some timeout.

Note that it is not enough to avoid jiffies by introducing a variant of
`CondVar::wait_timeout` that takes the timeout in msecs because we need
to be able to restart the sleep with the remaining sleep duration if it
is interrupted, and if the API takes msecs rather than jiffies, then
that would require a conversion roundtrip jiffies->msecs->jiffies that
is best avoided.

Reviewed-by: default avatarMartin Rodriguez Reboredo <yakoyoku@gmail.com>
Reviewed-by: default avatarTiago Lam <tiagolam@gmail.com>
Reviewed-by: default avatarBoqun Feng <boqun.feng@gmail.com>
Signed-off-by: default avatarAlice Ryhl <aliceryhl@google.com>
Reviewed-by: default avatarBenno Lossin <benno.lossin@proton.me>
Link: https://lore.kernel.org/r/20240108-rb-new-condvar-methods-v4-3-88e0c871cc05@google.com


[ Added `CondVarTimeoutResult` re-export and fixed typo. ]
Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
(cherry picked from commit e7b9b1ff
 https://github.com/Rust-for-Linux/linux.git

 rust-next)
Bug: 324206405
Change-Id: Id496273ae8346d9d6c73aa8eb4f1c6a8218deb43
Signed-off-by: default avatarAlice Ryhl <aliceryhl@google.com>
parent 117298b3
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment