@@ -17,21 +17,27 @@ use future::{FutureObj, LocalFutureObj};
17
17
18
18
/// A task executor.
19
19
///
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.
25
27
pub 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.
27
30
///
28
31
/// # Errors
29
32
///
30
33
/// The executor may be unable to spawn tasks, either because it has
31
34
/// 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 > ;
33
39
34
- /// Determine whether the executor is able to spawn new tasks.
40
+ /// Determines whether the executor is able to spawn new tasks.
35
41
///
36
42
/// # Returns
37
43
///
@@ -75,8 +81,8 @@ pub struct SpawnObjError {
75
81
/// The kind of error
76
82
pub kind : SpawnErrorKind ,
77
83
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 , ( ) > ,
80
86
}
81
87
82
88
/// The result of a failed spawn
@@ -85,6 +91,6 @@ pub struct SpawnLocalObjError {
85
91
/// The kind of error
86
92
pub kind : SpawnErrorKind ,
87
93
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 , ( ) > ,
90
96
}
0 commit comments