@@ -44,11 +44,11 @@ then it will have registered the current thread already, and hence
44
44
45
45
A key concept of the futures.rs library is that of an * executor* . The
46
46
executor is the runtime that first invokes the top-level future
47
- (` T_map ` , in our example). This is precisely the role that Rayon
47
+ (` F_map ` , in our example). This is precisely the role that Rayon
48
48
plays. Note that in any futures system there may be many
49
- interoperating execturs though.
49
+ interoperating executors though.
50
50
51
- Part of an executors job is to maintain some thread-local storage
51
+ Part of an executor's job is to maintain some thread-local storage
52
52
(TLS) when a future is executing. In particular, it must setup the
53
53
"current task" (basically a unique integer, although it's an opaque
54
54
type) as well as an "unpark object" of type
@@ -80,7 +80,7 @@ in the result.
80
80
81
81
### Future reference counting
82
82
83
- Each spawned future is represents by an ` Arc ` . This ` Arc ` actually has
83
+ Each spawned future is represented by an ` Arc ` . This ` Arc ` actually has
84
84
some interesting structure. Each of the edges in the diagram below
85
85
represents something that is "kept alive" by holding a ref count (in
86
86
some way, usually via an ` Arc ` ):
@@ -102,7 +102,7 @@ Let's walk through them:
102
102
103
103
- The incoming edge from ` F' ` represents the edge from the future that was returned
104
104
to the caller of ` spawn_future ` . This ensures that the future arc will
105
- not be freed so long as the caller is still interesting in looking at
105
+ not be freed so long as the caller is still interested in looking at
106
106
its result.
107
107
- The incoming edge from ` [ deque ] ` represents the fact that when the
108
108
future is enqueued into a thread-local deque (which it only
@@ -176,7 +176,7 @@ up its `contents.this` field as the current "notify" instance. Hence
176
176
if ` F ` returns ` NotReady ` , it will clone the ` this ` field and hold
177
177
onto it to signal us the future is ready to execute again.
178
178
179
- For now let's assume that ` F ` is complete and hence readys either
179
+ For now let's assume that ` F ` is complete and hence returns either
180
180
` Ok(Ready(_)) ` or ` Err(_) ` . In that case, the future can transition to
181
181
` COMPLETE ` . At this point, many bits of state that are no longer
182
182
needed (e.g., the future itself, but also the ` this ` field)
@@ -191,7 +191,7 @@ the `UNPARK` state and inject it into the registry.
191
191
192
192
However, due to the vagaries of thread-scheduling, it * can* happen
193
193
that ` notify() ` is called before we exit the ` EXECUTING ` state. For
194
- example, we might invoke ` F.poll() ` , which send the ` Unpark ` instance
194
+ example, we might invoke ` F.poll() ` , which sends the ` Unpark ` instance
195
195
to the I/O thread, which detects I/O, and invokes ` notify() ` , all
196
196
before ` F.poll() ` has returned. In that case, the ` notify() ` method
197
197
will transition the state (atomically, of course) to
@@ -215,7 +215,7 @@ then, we know we don't have to worry, the references are still valid.
215
215
216
216
As we transition into the * COMPLETE* state is where things get more
217
217
interesting. You'll notice that signaling the ` self.scope ` job as done
218
- the * last* thing that happens during that transition. Importantly,
218
+ is the * last* thing that happens during that transition. Importantly,
219
219
before that is done, we drop all access that we have to the type ` F ` :
220
220
that is, we store ` None ` into the fields that might reference values
221
221
of type ` F ` . This implies that we know that, whatever happens after we
@@ -265,8 +265,8 @@ So what about `poll()`? This is how the user gets the final result out
265
265
of the future. The important thing that it does is to access (and
266
266
effectively nullify) the field ` result ` , which stores the result of
267
267
the future and hence may have access to ` T ` and ` E ` values. These
268
- values may contain references...so how we know that they are still in
269
- scope? The answer is that those types are exposed in the user's type
268
+ values may contain references...so how do we know that they are still in
269
+ scope? The answer is that those types are exposed in the user's type
270
270
of the future, and hence the basic Rust type system should guarantee
271
271
that any references are still valid, or else the user shouldn't be
272
272
able to call ` poll() ` . (The same is true at the time of cancellation,
0 commit comments