Skip to content

Commit 60b69bf

Browse files
committed
Do not redefine modules in futures crate
1 parent 7ce5ce8 commit 60b69bf

File tree

12 files changed

+165
-453
lines changed

12 files changed

+165
-453
lines changed

futures-channel/src/lib.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
//! Asynchronous channels.
22
//!
3-
//! This crate provides channels that can be used to communicate between
4-
//! asynchronous tasks.
3+
//! Like threads, concurrent tasks sometimes need to communicate with each
4+
//! other. This module contains two basic abstractions for doing so:
55
//!
6-
//! All items of this library are only available when the `std` or `alloc` feature of this
6+
//! - [oneshot], a way of sending a single value from one task to another.
7+
//! - [mpsc], a multi-producer, single-consumer channel for sending values
8+
//! between tasks, analogous to the similarly-named structure in the standard
9+
//! library.
10+
//!
11+
//! All items are only available when the `std` or `alloc` feature of this
712
//! library is activated, and it is activated by default.
813
914
#![cfg_attr(feature = "cfg-target-has-atomic", feature(cfg_target_has_atomic))]

futures-executor/src/lib.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,40 @@
11
//! Built-in executors and related tools.
22
//!
3-
//! All items of this library are only available when the `std` feature of this
3+
//! All asynchronous computation occurs within an executor, which is
4+
//! capable of spawning futures as tasks. This module provides several
5+
//! built-in executors, as well as tools for building your own.
6+
//!
7+
//! All items are only available when the `std` feature of this
48
//! library is activated, and it is activated by default.
9+
//!
10+
//! # Using a thread pool (M:N task scheduling)
11+
//!
12+
//! Most of the time tasks should be executed on a [thread pool](ThreadPool).
13+
//! A small set of worker threads can handle a very large set of spawned tasks
14+
//! (which are much lighter weight than threads). Tasks spawned onto the pool
15+
//! with the [`spawn_ok`](ThreadPool::spawn_ok) function will run ambiently on
16+
//! the created threads.
17+
//!
18+
//! # Spawning additional tasks
19+
//!
20+
//! Tasks can be spawned onto a spawner by calling its [`spawn_obj`] method
21+
//! directly. In the case of `!Send` futures, [`spawn_local_obj`] can be used
22+
//! instead.
23+
//!
24+
//! # Single-threaded execution
25+
//!
26+
//! In addition to thread pools, it's possible to run a task (and the tasks
27+
//! it spawns) entirely within a single thread via the [`LocalPool`] executor.
28+
//! Aside from cutting down on synchronization costs, this executor also makes
29+
//! it possible to spawn non-`Send` tasks, via [`spawn_local_obj`]. The
30+
//! [`LocalPool`] is best suited for running I/O-bound tasks that do relatively
31+
//! little work between I/O operations.
32+
//!
33+
//! There is also a convenience function [`block_on`] for simply running a
34+
//! future to completion on the current thread.
35+
//!
36+
//! [`spawn_obj`]: https://docs.rs/futures/0.3/futures/task/trait.Spawn.html#tymethod.spawn_obj
37+
//! [`spawn_local_obj`]: https://docs.rs/futures/0.3/futures/task/trait.LocalSpawn.html#tymethod.spawn_local_obj
538
639
#![cfg_attr(not(feature = "std"), no_std)]
740

futures-util/src/compat/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! Futures 0.1 / 0.3 shims
1+
//! Interop between `futures` 0.1 and 0.3.
22
//!
33
//! This module is only available when the `compat` feature of this
44
//! library is activated.

futures-util/src/future/mod.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
//! Futures
1+
//! Asynchronous values.
22
//!
3-
//! This module contains a number of functions for working with `Future`s,
4-
//! including the [`FutureExt`] trait and the [`TryFutureExt`] trait which add
5-
//! methods to `Future` types.
3+
//! This module contains:
4+
//!
5+
//! - The [`Future`] trait.
6+
//! - The [`FutureExt`] and [`TryFutureExt`] trait, which provides adapters for
7+
//! chaining and composing futures.
8+
//! - Top-level future combinators like [`lazy`](lazy()) which creates a future
9+
//! from a closure that defines its return value, and [`ready`](ready()),
10+
//! which constructs a future with an immediate defined value.
611
712
#[cfg(feature = "alloc")]
813
pub use futures_core::future::{BoxFuture, LocalBoxFuture};

futures-util/src/io/mod.rs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
//! IO
1+
//! Asynchronous I/O.
22
//!
3-
//! This module contains a number of functions for working with
4-
//! `AsyncRead`, `AsyncWrite`, `AsyncSeek`, and `AsyncBufRead` types, including
5-
//! the `AsyncReadExt`, `AsyncWriteExt`, `AsyncSeekExt`, and `AsyncBufReadExt`
6-
//! traits which add methods to the `AsyncRead`, `AsyncWrite`, `AsyncSeek`,
7-
//! and `AsyncBufRead` types.
3+
//! This module is the asynchronous version of `std::io`. It defines four
4+
//! traits, [`AsyncRead`], [`AsyncWrite`], [`AsyncSeek`], and [`AsyncBufRead`],
5+
//! which mirror the `Read`, `Write`, `Seek`, and `BufRead` traits of the
6+
//! standard library. However, these traits integrate with the asynchronous
7+
//! task system, so that if an I/O object isn't ready for reading (or writing),
8+
//! the thread is not blocked, and instead the current task is queued to be
9+
//! woken when I/O is ready.
810
//!
9-
//! This module is only available when the `io` and `std` features of this
11+
//! In addition, the [`AsyncReadExt`], [`AsyncWriteExt`], [`AsyncSeekExt`], and
12+
//! [`AsyncBufReadExt`] extension traits offer a variety of useful combinators
13+
//! for operating with asynchronous I/O objects, including ways to work with
14+
//! them using futures, streams and sinks.
15+
//!
16+
//! This module is only available when the `std` feature of this
1017
//! library is activated, and it is activated by default.
1118
1219
#[cfg(feature = "io-compat")]

futures-util/src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,8 @@ pub mod io;
343343
#[doc(hidden)]
344344
pub use crate::io::{AsyncBufReadExt, AsyncReadExt, AsyncSeekExt, AsyncWriteExt};
345345

346+
#[cfg(feature = "alloc")]
347+
pub mod lock;
348+
346349
mod fns;
347350
mod unfold_state;
348-
349-
cfg_target_has_atomic! {
350-
#[cfg(feature = "alloc")]
351-
pub mod lock;
352-
}

futures-util/src/lock/mod.rs

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@
33
//! This module is only available when the `std` or `alloc` feature of this
44
//! library is activated, and it is activated by default.
55
6-
#[cfg(feature = "std")]
7-
mod mutex;
8-
#[cfg(feature = "std")]
9-
pub use self::mutex::{MappedMutexGuard, Mutex, MutexLockFuture, MutexGuard};
6+
cfg_target_has_atomic! {
7+
#[cfg(feature = "std")]
8+
mod mutex;
9+
#[cfg(feature = "std")]
10+
pub use self::mutex::{MappedMutexGuard, Mutex, MutexLockFuture, MutexGuard};
1011

11-
#[cfg(any(feature = "bilock", feature = "sink", feature = "io"))]
12-
#[cfg_attr(docsrs, doc(cfg(feature = "bilock")))]
13-
#[cfg_attr(not(feature = "bilock"), allow(unreachable_pub))]
14-
mod bilock;
15-
#[cfg(feature = "bilock")]
16-
#[cfg_attr(docsrs, doc(cfg(feature = "bilock")))]
17-
pub use self::bilock::{BiLock, BiLockAcquire, BiLockGuard, ReuniteError};
18-
#[cfg(any(feature = "sink", feature = "io"))]
19-
#[cfg(not(feature = "bilock"))]
20-
pub(crate) use self::bilock::BiLock;
12+
#[cfg(any(feature = "bilock", feature = "sink", feature = "io"))]
13+
#[cfg_attr(docsrs, doc(cfg(feature = "bilock")))]
14+
#[cfg_attr(not(feature = "bilock"), allow(unreachable_pub))]
15+
mod bilock;
16+
#[cfg(feature = "bilock")]
17+
#[cfg_attr(docsrs, doc(cfg(feature = "bilock")))]
18+
pub use self::bilock::{BiLock, BiLockAcquire, BiLockGuard, ReuniteError};
19+
#[cfg(any(feature = "sink", feature = "io"))]
20+
#[cfg(not(feature = "bilock"))]
21+
pub(crate) use self::bilock::BiLock;
22+
}

futures-util/src/never.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
//! Definition of the `Never` type,
2-
//! a stand-in for the `!` type until it becomes stable.
1+
//! This module contains the `Never` type.
2+
//!
3+
//! Values of this type can never be created and will never exist.
34
45
/// A type with no possible values.
56
///

futures-util/src/sink/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
//! Sinks
1+
//! Asynchronous sinks.
22
//!
3-
//! This module contains a number of functions for working with `Sink`s,
4-
//! including the `SinkExt` trait which adds methods to `Sink` types.
3+
//! This module contains:
54
//!
6-
//! This module is only available when the `sink` feature of this
7-
//! library is activated, and it is activated by default.
5+
//! - The [`Sink`] trait, which allows you to asynchronously write data.
6+
//! - The [`SinkExt`] trait, which provides adapters for chaining and composing
7+
//! sinks.
88
99
use crate::future::Either;
1010
use core::pin::Pin;

futures-util/src/stream/mod.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
1-
//! Streams
1+
//! Asynchronous streams.
22
//!
3-
//! This module contains a number of functions for working with `Stream`s,
4-
//! including the [`StreamExt`] trait and the [`TryStreamExt`] trait which add
5-
//! methods to `Stream` types
3+
//! This module contains:
4+
//!
5+
//! - The [`Stream`] trait, for objects that can asynchronously produce a
6+
//! sequence of values.
7+
//! - The [`StreamExt`] and [`TryStreamExt`] trait, which provides adapters for
8+
//! chaining and composing streams.
9+
//! - Top-level stream constructors like [`iter`](iter()) which creates a
10+
//! stream from an iterator.
611
712
#[cfg(feature = "alloc")]
813
pub use futures_core::stream::{BoxStream, LocalBoxStream};

futures-util/src/task/mod.rs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,25 @@
1-
//! Task notification
1+
//! Tools for working with tasks.
2+
//!
3+
//! This module contains:
4+
//!
5+
//! - [`Spawn`], a trait for spawning new tasks.
6+
//! - [`Context`], a context of an asynchronous task,
7+
//! including a handle for waking up the task.
8+
//! - [`Waker`], a handle for waking up a task.
9+
//!
10+
//! The remaining types and traits in the module are used for implementing
11+
//! executors or dealing with synchronization issues around task wakeup.
12+
13+
pub use futures_core::task::{Context, Poll, Waker, RawWaker, RawWakerVTable};
14+
15+
pub use futures_task::{
16+
Spawn, LocalSpawn, SpawnError,
17+
FutureObj, LocalFutureObj, UnsafeFutureObj,
18+
};
19+
20+
pub use futures_task::noop_waker;
21+
#[cfg(feature = "std")]
22+
pub use futures_task::noop_waker_ref;
223

324
cfg_target_has_atomic! {
425
#[cfg(feature = "alloc")]
@@ -15,14 +36,3 @@ cfg_target_has_atomic! {
1536

1637
mod spawn;
1738
pub use self::spawn::{SpawnExt, LocalSpawnExt};
18-
19-
pub use futures_core::task::{Context, Poll, Waker, RawWaker, RawWakerVTable};
20-
21-
pub use futures_task::{
22-
Spawn, LocalSpawn, SpawnError,
23-
FutureObj, LocalFutureObj, UnsafeFutureObj,
24-
};
25-
26-
pub use futures_task::noop_waker;
27-
#[cfg(feature = "std")]
28-
pub use futures_task::noop_waker_ref;

0 commit comments

Comments
 (0)