Skip to content

Commit

Permalink
cfg-target-has-atomic
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Mar 18, 2019
1 parent d6b7f5b commit cb135f7
Show file tree
Hide file tree
Showing 6 changed files with 159 additions and 3 deletions.
8 changes: 8 additions & 0 deletions futures-util/src/future/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,16 @@ pub use self::unit_error::UnitError;
mod chain;
pub(crate) use self::chain::Chain;

#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
mod abortable;
#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
pub use self::abortable::{abortable, Abortable, AbortHandle, AbortRegistration, Aborted};

Expand Down
4 changes: 4 additions & 0 deletions futures-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,5 +101,9 @@ pub mod io;
#[cfg(feature = "std")]
#[doc(hidden)] pub use crate::io::{AsyncReadExt, AsyncWriteExt};

#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
pub mod lock;
72 changes: 72 additions & 0 deletions futures-util/src/stream/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,29 @@ pub use self::unfold::{unfold, Unfold};
mod zip;
pub use self::zip::Zip;

#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
mod buffer_unordered;
#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
pub use self::buffer_unordered::BufferUnordered;

#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
mod buffered;
#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
pub use self::buffered::Buffered;

Expand All @@ -119,28 +135,68 @@ mod chunks;
#[cfg(feature = "alloc")]
pub use self::chunks::Chunks;

#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
mod for_each_concurrent;
#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
pub use self::for_each_concurrent::ForEachConcurrent;

#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
mod futures_ordered;
#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
pub use self::futures_ordered::{futures_ordered, FuturesOrdered};

#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
mod futures_unordered;
#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
pub use self::futures_unordered::{futures_unordered, FuturesUnordered};

#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
mod split;
#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
pub use self::split::{SplitStream, SplitSink, ReuniteError};

#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
mod select_all;
#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
pub use self::select_all::{select_all, SelectAll};

Expand Down Expand Up @@ -613,6 +669,10 @@ pub trait StreamExt: Stream {
/// await!(fut);
/// # })
/// ```
#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
fn for_each_concurrent<Fut, F>(
self,
Expand Down Expand Up @@ -809,6 +869,10 @@ pub trait StreamExt: Stream {
///
/// This method is only available when the `std` feature of this
/// library is activated, and it is activated by default.
#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
fn buffered(self, n: usize) -> Buffered<Self>
where Self::Item: Future,
Expand Down Expand Up @@ -853,6 +917,10 @@ pub trait StreamExt: Stream {
/// assert_eq!(await!(buffered.next()), None);
/// # })
/// ```
#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
fn buffer_unordered(self, n: usize) -> BufferUnordered<Self>
where Self::Item: Future,
Expand Down Expand Up @@ -992,6 +1060,10 @@ pub trait StreamExt: Stream {
///
/// This method is only available when the `std` feature of this
/// library is activated, and it is activated by default.
#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
fn split(self) -> (SplitSink<Self>, SplitStream<Self>)
where Self: Sink + Sized
Expand Down
21 changes: 21 additions & 0 deletions futures-util/src/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
/// A macro for creating a `RawWaker` vtable for a type that implements
/// the `ArcWake` trait.
#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
macro_rules! waker_vtable {
($ty:ident) => {
&RawWakerVTable {
Expand All @@ -12,8 +17,16 @@ macro_rules! waker_vtable {
};
}

#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
mod arc_wake;
#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
pub use self::arc_wake::ArcWake;

Expand All @@ -25,8 +38,16 @@ pub use self::noop_waker::noop_waker_ref;
mod spawn;
pub use self::spawn::{SpawnExt, LocalSpawnExt};

#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
mod waker_ref;
#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
pub use self::waker_ref::{waker_ref, WakerRef};

Expand Down
28 changes: 28 additions & 0 deletions futures-util/src/try_stream/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,35 @@ pub use self::try_fold::TryFold;
mod try_skip_while;
pub use self::try_skip_while::TrySkipWhile;

#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
mod try_buffer_unordered;
#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
pub use self::try_buffer_unordered::TryBufferUnordered;

#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
mod try_for_each_concurrent;
#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
pub use self::try_for_each_concurrent::TryForEachConcurrent;
#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
use futures_core::future::Future;

Expand Down Expand Up @@ -310,6 +330,10 @@ pub trait TryStreamExt: TryStream {
/// assert_eq!(Err(oneshot::Canceled), await!(fut));
/// # })
/// ```
#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
fn try_for_each_concurrent<Fut, F>(
self,
Expand Down Expand Up @@ -545,6 +569,10 @@ pub trait TryStreamExt: TryStream {
/// assert_eq!(await!(buffered.next()), Some(Err("error in the stream")));
/// # })
/// ```
#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
fn try_buffer_unordered(self, n: usize) -> TryBufferUnordered<Self>
where Self::Ok: TryFuture<Error = Self::Error>,
Expand Down
29 changes: 26 additions & 3 deletions futures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,16 @@ pub mod future {
Join5, Map, Then,
};

#[cfg(feature = "alloc")]
pub use futures_util::future::{join_all, JoinAll};

#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
pub use futures_util::future::{
abortable, Abortable, AbortHandle, AbortRegistration, Aborted,

join_all, JoinAll,
};

#[cfg(feature = "std")]
Expand Down Expand Up @@ -340,13 +345,23 @@ pub mod stream {
Take, TakeWhile, Then, Zip
};

#[cfg(feature = "alloc")]
pub use futures_util::stream::{
// For StreamExt:
Chunks,
};

#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
pub use futures_util::stream::{
futures_ordered, FuturesOrdered,
futures_unordered, FuturesUnordered,

// For StreamExt:
BufferUnordered, Buffered, Chunks, SplitStream, SplitSink,
BufferUnordered, Buffered, SplitStream, SplitSink,

select_all, SelectAll,
};
Expand All @@ -365,6 +380,10 @@ pub mod stream {
// ToDo: AndThen, ErrInto, InspectErr, MapErr, OrElse
};

#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
pub use futures_util::try_stream::{
// For TryStreamExt:
Expand All @@ -391,6 +410,10 @@ pub mod task {

pub use futures_util::task::noop_waker;

#[cfg_attr(
feature = "cfg-target-has-atomic",
cfg(all(target_has_atomic = "cas", target_has_atomic = "ptr"))
)]
#[cfg(feature = "alloc")]
pub use futures_util::task::{
WakerRef, waker_ref, ArcWake,
Expand Down

0 comments on commit cb135f7

Please sign in to comment.