@@ -151,13 +151,73 @@ pub use futures_util::io;
151
151
152
152
#[ cfg( feature = "executor" ) ]
153
153
#[ cfg_attr( docsrs, doc( cfg( feature = "executor" ) ) ) ]
154
- #[ doc( inline) ]
155
- pub use futures_executor as executor;
154
+ pub mod executor {
155
+ //! Built-in executors and related tools.
156
+ //!
157
+ //! All asynchronous computation occurs within an executor, which is
158
+ //! capable of spawning futures as tasks. This module provides several
159
+ //! built-in executors, as well as tools for building your own.
160
+ //!
161
+ //!
162
+ //! This module is only available when the `executor` feature of this
163
+ //! library is activated.
164
+ //!
165
+ //! # Using a thread pool (M:N task scheduling)
166
+ //!
167
+ //! Most of the time tasks should be executed on a [thread pool](ThreadPool).
168
+ //! A small set of worker threads can handle a very large set of spawned tasks
169
+ //! (which are much lighter weight than threads). Tasks spawned onto the pool
170
+ //! with the [`spawn_ok`](ThreadPool::spawn_ok) function will run ambiently on
171
+ //! the created threads.
172
+ //!
173
+ //! # Spawning additional tasks
174
+ //!
175
+ //! Tasks can be spawned onto a spawner by calling its [`spawn_obj`] method
176
+ //! directly. In the case of `!Send` futures, [`spawn_local_obj`] can be used
177
+ //! instead.
178
+ //!
179
+ //! # Single-threaded execution
180
+ //!
181
+ //! In addition to thread pools, it's possible to run a task (and the tasks
182
+ //! it spawns) entirely within a single thread via the [`LocalPool`] executor.
183
+ //! Aside from cutting down on synchronization costs, this executor also makes
184
+ //! it possible to spawn non-`Send` tasks, via [`spawn_local_obj`]. The
185
+ //! [`LocalPool`] is best suited for running I/O-bound tasks that do relatively
186
+ //! little work between I/O operations.
187
+ //!
188
+ //! There is also a convenience function [`block_on`] for simply running a
189
+ //! future to completion on the current thread.
190
+ //!
191
+ //! [`spawn_obj`]: https://docs.rs/futures/0.3/futures/task/trait.Spawn.html#tymethod.spawn_obj
192
+ //! [`spawn_local_obj`]: https://docs.rs/futures/0.3/futures/task/trait.LocalSpawn.html#tymethod.spawn_local_obj
193
+
194
+ pub use futures_executor:: {
195
+ block_on, block_on_stream, enter, BlockingStream , Enter , EnterError , LocalPool ,
196
+ LocalSpawner ,
197
+ } ;
198
+
199
+ #[ cfg( feature = "thread-pool" ) ]
200
+ #[ cfg_attr( docsrs, doc( cfg( feature = "thread-pool" ) ) ) ]
201
+ pub use futures_executor:: { ThreadPool , ThreadPoolBuilder } ;
202
+ }
156
203
157
204
#[ cfg( feature = "compat" ) ]
158
205
#[ cfg_attr( docsrs, doc( cfg( feature = "compat" ) ) ) ]
159
- #[ doc( inline) ]
160
- pub use futures_util:: compat;
206
+ pub mod compat {
207
+ //! Interop between `futures` 0.1 and 0.3.
208
+ //!
209
+ //! This module is only available when the `compat` feature of this
210
+ //! library is activated.
211
+
212
+ pub use futures_util:: compat:: {
213
+ Compat , Compat01As03 , Compat01As03Sink , CompatSink , Executor01As03 , Executor01CompatExt ,
214
+ Executor01Future , Future01CompatExt , Sink01CompatExt , Stream01CompatExt ,
215
+ } ;
216
+
217
+ #[ cfg( feature = "io-compat" ) ]
218
+ #[ cfg_attr( docsrs, doc( cfg( feature = "io-compat" ) ) ) ]
219
+ pub use futures_util:: compat:: { AsyncRead01CompatExt , AsyncWrite01CompatExt } ;
220
+ }
161
221
162
222
pub mod prelude {
163
223
//! A "prelude" for crates using the `futures` crate.
0 commit comments