@@ -17,21 +17,27 @@ use future::{FutureObj, LocalFutureObj};
1717
1818/// A task executor.
1919///
20- /// A *task* is a `()`-producing async value that runs at the top level, and will
21- /// be `poll`ed until completion. It's also the unit at which wake-up
22- /// notifications occur. Executors, such as thread pools, allow tasks to be
23- /// spawned and are responsible for putting tasks onto ready queues when
24- /// they are woken up, and polling them when they are ready.
20+ /// Futures are polled until completion by tasks, a kind of lightweight
21+ /// "thread". A *task executor* is responsible for the creation of these tasks
22+ /// and the coordination of their execution on real operating system threads. In
23+ /// particular, whenever a task signals that it can make further progress via a
24+ /// wake-up notification, it is the responsibility of the task executor to put
25+ /// the task into a queue to continue executing it, i.e. polling the future in
26+ /// it, later.
2527pub trait Executor {
26- /// Spawn the given task, polling it until completion.
28+ /// Spawns a new task with the given future. The future will be polled until
29+ /// completion.
2730 ///
2831 /// # Errors
2932 ///
3033 /// The executor may be unable to spawn tasks, either because it has
3134 /// been shut down or is resource-constrained.
32- fn spawn_obj ( & mut self , task : FutureObj < ' static , ( ) > ) -> Result < ( ) , SpawnObjError > ;
35+ fn spawn_obj (
36+ & mut self ,
37+ future : FutureObj < ' static , ( ) > ,
38+ ) -> Result < ( ) , SpawnObjError > ;
3339
34- /// Determine whether the executor is able to spawn new tasks.
40+ /// Determines whether the executor is able to spawn new tasks.
3541 ///
3642 /// # Returns
3743 ///
@@ -75,8 +81,8 @@ pub struct SpawnObjError {
7581 /// The kind of error
7682 pub kind : SpawnErrorKind ,
7783
78- /// The task for which spawning was attempted
79- pub task : FutureObj < ' static , ( ) > ,
84+ /// The future for which spawning inside a task was attempted
85+ pub future : FutureObj < ' static , ( ) > ,
8086}
8187
8288/// The result of a failed spawn
@@ -85,6 +91,6 @@ pub struct SpawnLocalObjError {
8591 /// The kind of error
8692 pub kind : SpawnErrorKind ,
8793
88- /// The task for which spawning was attempted
89- pub task : LocalFutureObj < ' static , ( ) > ,
94+ /// The future for which spawning inside a task was attempted
95+ pub future : LocalFutureObj < ' static , ( ) > ,
9096}
0 commit comments