cros_async: update Timer & sleep docs for Windows.

base::Timer's sleep may wake early on Windows, which has knockon effects
here where we consume it.

BUG=b:229680949
TEST=n/a

Change-Id: I44a8f78e3dbc01ef562101c2706b89d2a88e5bf7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3617161
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Noah Gold 2022-04-29 11:22:10 -07:00 committed by Chromeos LUCI
parent fb874a8a9f
commit dc8d1dbdca

View file

@ -18,11 +18,17 @@ impl TimerAsync {
}
/// Gets the next value from the timer.
///
/// NOTE: on Windows, this may return/wake early. See `base::Timer` docs
/// for details.
pub async fn next_val(&self) -> AsyncResult<u64> {
self.io_source.wait_for_handle().await
}
/// Async sleep for the given duration
/// Async sleep for the given duration.
///
/// NOTE: on Windows, this sleep may wake early. See `base::Timer` docs
/// for details.
pub async fn sleep(ex: &Executor, dur: Duration) -> std::result::Result<(), Error> {
let mut tfd = Timer::new().map_err(Error::Timer)?;
tfd.reset(dur, None).map_err(Error::Timer)?;