diff --git a/cros_async/src/blocking.rs b/cros_async/src/blocking.rs new file mode 100644 index 0000000000..ae79d2b29d --- /dev/null +++ b/cros_async/src/blocking.rs @@ -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::*; diff --git a/cros_async/src/sync/blocking.rs b/cros_async/src/blocking/block_on.rs similarity index 100% rename from cros_async/src/sync/blocking.rs rename to cros_async/src/blocking/block_on.rs diff --git a/cros_async/src/lib.rs b/cros_async/src/lib.rs index 0cc4405598..810c1903c4 100644 --- a/cros_async/src/lib.rs +++ b/cros_async/src/lib.rs @@ -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; diff --git a/cros_async/src/sync.rs b/cros_async/src/sync.rs index 80dec3858b..e2c1a1452f 100644 --- a/cros_async/src/sync.rs +++ b/cros_async/src/sync.rs @@ -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; diff --git a/cros_async/src/sync/cv.rs b/cros_async/src/sync/cv.rs index fa8cf50bb1..cc7512129f 100644 --- a/cros_async/src/sync/cv.rs +++ b/cros_async/src/sync/cv.rs @@ -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; diff --git a/cros_async/src/sync/mu.rs b/cros_async/src/sync/mu.rs index fbe2079671..b4e41f77f1 100644 --- a/cros_async/src/sync/mu.rs +++ b/cros_async/src/sync/mu.rs @@ -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);