// Copyright 2021 The ChromiumOS Authors1// Use of this source code is governed by a BSD-style license that can be2// found in the LICENSE file.34//! Virtio device async helper functions.56use anyhow::Context;7use anyhow::Result;8use base::Event;9use cros_async::EventAsync;10use cros_async::Executor;1112/// Async task that waits for a signal from `event`. Once this event is readable, exit. Exiting13/// this future will cause the main loop to break and the worker thread to exit.14pub async fn await_and_exit(ex: &Executor, event: Event) -> Result<()> {15let event_async = EventAsync::new(event, ex).context("failed to create EventAsync")?;16let _ = event_async.next_val().await;17Ok(())18}192021