Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
google
GitHub Repository: google/crosvm
Path: blob/main/devices/src/virtio/async_utils.rs
5394 views
1
// Copyright 2021 The ChromiumOS Authors
2
// Use of this source code is governed by a BSD-style license that can be
3
// found in the LICENSE file.
4
5
//! Virtio device async helper functions.
6
7
use anyhow::Context;
8
use anyhow::Result;
9
use base::Event;
10
use cros_async::EventAsync;
11
use cros_async::Executor;
12
13
/// Async task that waits for a signal from `event`. Once this event is readable, exit. Exiting
14
/// this future will cause the main loop to break and the worker thread to exit.
15
pub async fn await_and_exit(ex: &Executor, event: Event) -> Result<()> {
16
let event_async = EventAsync::new(event, ex).context("failed to create EventAsync")?;
17
let _ = event_async.next_val().await;
18
Ok(())
19
}
20
21