mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-24 12:34:31 +00:00
cros_async: Make block_on a top-level function
This doesn't really have anything to do with synchronization so move it into its own module and export it as a top-level function. BUG=b:179755651 TEST=cargo test Change-Id: Icb733c36ee1d4cebcb445e47289c92b9b77a278b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2987583 Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org> Reviewed-by: Noah Gold <nkgold@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
This commit is contained in:
parent
1dbffd13c6
commit
79bcb99530
6 changed files with 23 additions and 7 deletions
7
cros_async/src/blocking.rs
Normal file
7
cros_async/src/blocking.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
// Copyright 2021 The Chromium OS Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
mod block_on;
|
||||
|
||||
pub use block_on::*;
|
|
@ -58,6 +58,7 @@
|
|||
//! See the docs for `IoSourceExt` if support for kernels <5.4 is required. Focus on `UringSource` if
|
||||
//! all systems have support for io_uring.
|
||||
|
||||
mod blocking;
|
||||
mod complete;
|
||||
mod event;
|
||||
mod executor;
|
||||
|
@ -73,6 +74,7 @@ mod uring_executor;
|
|||
mod uring_source;
|
||||
mod waker;
|
||||
|
||||
pub use blocking::block_on;
|
||||
pub use event::EventAsync;
|
||||
pub use executor::Executor;
|
||||
pub use fd_executor::FdExecutor;
|
||||
|
|
|
@ -2,13 +2,11 @@
|
|||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
mod blocking;
|
||||
mod cv;
|
||||
mod mu;
|
||||
mod spin;
|
||||
mod waiter;
|
||||
|
||||
pub use blocking::block_on;
|
||||
pub use cv::Condvar;
|
||||
pub use mu::Mutex;
|
||||
pub use spin::SpinLock;
|
||||
|
|
|
@ -28,7 +28,10 @@ const HAS_WAITERS: usize = 1 << 1;
|
|||
/// use std::thread;
|
||||
/// use std::sync::mpsc::channel;
|
||||
///
|
||||
/// use cros_async::sync::{block_on, Condvar, Mutex};
|
||||
/// use cros_async::{
|
||||
/// block_on,
|
||||
/// sync::{Condvar, Mutex},
|
||||
/// };
|
||||
///
|
||||
/// const N: usize = 13;
|
||||
///
|
||||
|
@ -93,7 +96,10 @@ impl Condvar {
|
|||
/// # use std::sync::Arc;
|
||||
/// # use std::thread;
|
||||
///
|
||||
/// # use cros_async::sync::{block_on, Condvar, Mutex};
|
||||
/// # use cros_async::{
|
||||
/// # block_on,
|
||||
/// # sync::{Condvar, Mutex},
|
||||
/// # };
|
||||
///
|
||||
/// # let mu = Arc::new(Mutex::new(false));
|
||||
/// # let cv = Arc::new(Condvar::new());
|
||||
|
@ -458,7 +464,7 @@ mod test {
|
|||
use futures_executor::{LocalPool, LocalSpawner, ThreadPool};
|
||||
use futures_util::task::LocalSpawnExt;
|
||||
|
||||
use crate::sync::{block_on, Mutex};
|
||||
use crate::{block_on, sync::Mutex};
|
||||
|
||||
// Dummy waker used when we want to manually drive futures.
|
||||
struct TestWaker;
|
||||
|
|
|
@ -651,7 +651,7 @@ fn cancel_waiter(raw: usize, waiter: &Waiter, wake_next: bool) {
|
|||
/// use std::thread;
|
||||
/// use std::sync::mpsc::channel;
|
||||
///
|
||||
/// use cros_async::sync::{block_on, Mutex};
|
||||
/// use cros_async::{block_on, sync::Mutex};
|
||||
///
|
||||
/// const N: usize = 10;
|
||||
///
|
||||
|
@ -899,7 +899,10 @@ mod test {
|
|||
use futures_executor::{LocalPool, ThreadPool};
|
||||
use futures_util::task::LocalSpawnExt;
|
||||
|
||||
use crate::sync::{block_on, Condvar, SpinLock};
|
||||
use crate::{
|
||||
block_on,
|
||||
sync::{Condvar, SpinLock},
|
||||
};
|
||||
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
struct NonCopy(u32);
|
||||
|
|
Loading…
Reference in a new issue