diff --git a/asyncband/src/channel/mod.rs b/asyncband/src/channel/mod.rs new file mode 100644 index 0000000..58689a6 --- /dev/null +++ b/asyncband/src/channel/mod.rs @@ -0,0 +1,21 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. + +#[cfg(feature = "mpsc")] +pub mod mpsc; +#[cfg(feature = "oneshot")] +pub mod oneshot; diff --git a/asyncband/src/mpsc/bounded.rs b/asyncband/src/channel/mpsc/bounded.rs similarity index 98% rename from asyncband/src/mpsc/bounded.rs rename to asyncband/src/channel/mpsc/bounded.rs index 60f0da0..08aefd4 100644 --- a/asyncband/src/mpsc/bounded.rs +++ b/asyncband/src/channel/mpsc/bounded.rs @@ -28,13 +28,13 @@ use std::sync::atomic::Ordering; use std::task::Context; use std::task::Poll; +use super::RecvError; +use super::SendError; +use super::TryRecvError; +use super::TrySendError; use crate::internal::atomic_waker::AtomicWaker; use crate::internal::semaphore::Acquire; use crate::internal::semaphore::Semaphore; -use crate::mpsc::RecvError; -use crate::mpsc::SendError; -use crate::mpsc::TryRecvError; -use crate::mpsc::error::TrySendError; /// Creates a bounded mpsc channel for communicating between asynchronous /// tasks with backpressure. diff --git a/asyncband/src/mpsc/error.rs b/asyncband/src/channel/mpsc/error.rs similarity index 100% rename from asyncband/src/mpsc/error.rs rename to asyncband/src/channel/mpsc/error.rs diff --git a/asyncband/src/mpsc/mod.rs b/asyncband/src/channel/mpsc/mod.rs similarity index 100% rename from asyncband/src/mpsc/mod.rs rename to asyncband/src/channel/mpsc/mod.rs diff --git a/asyncband/src/mpsc/unbounded.rs b/asyncband/src/channel/mpsc/unbounded.rs similarity index 99% rename from asyncband/src/mpsc/unbounded.rs rename to asyncband/src/channel/mpsc/unbounded.rs index eb446be..3ee892a 100644 --- a/asyncband/src/mpsc/unbounded.rs +++ b/asyncband/src/channel/mpsc/unbounded.rs @@ -26,10 +26,10 @@ use std::sync::atomic::Ordering; use std::task::Context; use std::task::Poll; +use super::RecvError; +use super::SendError; +use super::TryRecvError; use crate::internal::atomic_waker::AtomicWaker; -use crate::mpsc::RecvError; -use crate::mpsc::SendError; -use crate::mpsc::TryRecvError; /// Creates an unbounded mpsc channel for communicating between asynchronous /// tasks without backpressure. diff --git a/asyncband/src/oneshot/mod.rs b/asyncband/src/channel/oneshot/mod.rs similarity index 100% rename from asyncband/src/oneshot/mod.rs rename to asyncband/src/channel/oneshot/mod.rs diff --git a/asyncband/src/oneshot/receiver.rs b/asyncband/src/channel/oneshot/receiver.rs similarity index 98% rename from asyncband/src/oneshot/receiver.rs rename to asyncband/src/channel/oneshot/receiver.rs index 29f913b..7d232dc 100644 --- a/asyncband/src/oneshot/receiver.rs +++ b/asyncband/src/channel/oneshot/receiver.rs @@ -24,16 +24,16 @@ use std::sync::atomic::fence; use std::task::Context; use std::task::Poll; -use crate::oneshot::AWAKING; -use crate::oneshot::Channel; -use crate::oneshot::DISCONNECTED; -use crate::oneshot::EMPTY; -use crate::oneshot::MESSAGE; -use crate::oneshot::RECEIVING; +use super::AWAKING; +use super::Channel; +use super::DISCONNECTED; +use super::EMPTY; +use super::MESSAGE; +use super::RECEIVING; #[cfg(doc)] -use crate::oneshot::Sender; -use crate::oneshot::deallocate_empty_channel; -use crate::oneshot::drop_message_and_deallocate_channel; +use super::Sender; +use super::deallocate_empty_channel; +use super::drop_message_and_deallocate_channel; /// Receives a value from the associated [`Sender`]. pub struct Receiver { diff --git a/asyncband/src/oneshot/sender.rs b/asyncband/src/channel/oneshot/sender.rs similarity index 97% rename from asyncband/src/oneshot/sender.rs rename to asyncband/src/channel/oneshot/sender.rs index adf45ee..58a712c 100644 --- a/asyncband/src/oneshot/sender.rs +++ b/asyncband/src/channel/oneshot/sender.rs @@ -22,15 +22,15 @@ use std::ptr::NonNull; use std::sync::atomic::Ordering; use std::sync::atomic::fence; -use crate::oneshot::Channel; -use crate::oneshot::DISCONNECTED; -use crate::oneshot::EMPTY; -use crate::oneshot::MESSAGE; -use crate::oneshot::RECEIVING; +use super::Channel; +use super::DISCONNECTED; +use super::EMPTY; +use super::MESSAGE; +use super::RECEIVING; #[cfg(doc)] -use crate::oneshot::Receiver; -use crate::oneshot::deallocate_empty_channel; -use crate::oneshot::drop_message_and_deallocate_channel; +use super::Receiver; +use super::deallocate_empty_channel; +use super::drop_message_and_deallocate_channel; /// Sends a value to the associated [`Receiver`]. pub struct Sender { diff --git a/asyncband/src/oneshot/tests.rs b/asyncband/src/channel/oneshot/tests.rs similarity index 100% rename from asyncband/src/oneshot/tests.rs rename to asyncband/src/channel/oneshot/tests.rs diff --git a/asyncband/src/lib.rs b/asyncband/src/lib.rs index 41a52d8..733275a 100644 --- a/asyncband/src/lib.rs +++ b/asyncband/src/lib.rs @@ -100,6 +100,7 @@ //! //! While incubation status is not necessarily a reflection of the completeness or stability of the //! code, it does indicate that the project has yet to be fully endorsed by the ASF. +mod channel; mod internal; #[cfg(feature = "barrier")] @@ -111,7 +112,7 @@ pub mod condvar; #[cfg(feature = "latch")] pub mod latch; #[cfg(feature = "mpsc")] -pub mod mpsc; +pub use self::channel::mpsc; #[cfg(feature = "mutex")] pub mod mutex; #[cfg(any( @@ -122,7 +123,7 @@ pub mod mutex; ))] pub mod once; #[cfg(feature = "oneshot")] -pub mod oneshot; +pub use self::channel::oneshot; #[cfg(feature = "pool")] pub mod pool; #[cfg(feature = "rwlock")]