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. await_and_exit(ex: &Executor, event: Event) -> Result<()>15pub 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