Skip to content

Commit 346bcdf

Browse files
623: Filtermap test use sum r=cuviper a=seanchen1991 The `filter_map` test collects the parallel iterator using `sum`, but it collects the sequential iterator using `fold`. These should probably be brought to parity with each other, unless there's some rationale with using `fold` on the sequential iterator that I'm not seeing. Also a few typo fixes in READMEs that I corrected locally a while ago. If it's preferable that I submit a separate PR for those, I'm happy to do so. Co-authored-by: Sean <[email protected]>
2 parents b84a662 + 93331b4 commit 346bcdf

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

rayon-futures/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ then it will have registered the current thread already, and hence
4444

4545
A key concept of the futures.rs library is that of an *executor*. The
4646
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
4848
plays. Note that in any futures system there may be many
49-
interoperating execturs though.
49+
interoperating executors though.
5050

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
5252
(TLS) when a future is executing. In particular, it must setup the
5353
"current task" (basically a unique integer, although it's an opaque
5454
type) as well as an "unpark object" of type
@@ -80,7 +80,7 @@ in the result.
8080

8181
### Future reference counting
8282

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
8484
some interesting structure. Each of the edges in the diagram below
8585
represents something that is "kept alive" by holding a ref count (in
8686
some way, usually via an `Arc`):
@@ -102,7 +102,7 @@ Let's walk through them:
102102

103103
- The incoming edge from `F'` represents the edge from the future that was returned
104104
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
106106
its result.
107107
- The incoming edge from `[ deque ]` represents the fact that when the
108108
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
176176
if `F` returns `NotReady`, it will clone the `this` field and hold
177177
onto it to signal us the future is ready to execute again.
178178

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
180180
`Ok(Ready(_))` or `Err(_)`. In that case, the future can transition to
181181
`COMPLETE`. At this point, many bits of state that are no longer
182182
needed (e.g., the future itself, but also the `this` field)
@@ -191,7 +191,7 @@ the `UNPARK` state and inject it into the registry.
191191

192192
However, due to the vagaries of thread-scheduling, it *can* happen
193193
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
195195
to the I/O thread, which detects I/O, and invokes `notify()`, all
196196
before `F.poll()` has returned. In that case, the `notify()` method
197197
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.
215215

216216
As we transition into the *COMPLETE* state is where things get more
217217
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,
219219
before that is done, we drop all access that we have to the type `F`:
220220
that is, we store `None` into the fields that might reference values
221221
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
265265
of the future. The important thing that it does is to access (and
266266
effectively nullify) the field `result`, which stores the result of
267267
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
270270
of the future, and hence the basic Rust type system should guarantee
271271
that any references are still valid, or else the user shouldn't be
272272
able to call `poll()`. (The same is true at the time of cancellation,

src/iter/plumbing/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ a very simple consumer because it doesn't need to thread any state
7070
between items at all.)
7171

7272
Now, the `for_each` call will pass this consumer to the base iterator,
73-
which is the `flat_map`. It will do by calling the `drive_unindexed`
73+
which is the `flat_map`. It will do this by calling the `drive_unindexed`
7474
method on the `ParallelIterator` trait. `drive_unindexed` basically
7575
says "produce items for this iterator and feed them to this consumer";
7676
it only works for unindexed consumers.

src/iter/test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,7 @@ pub fn check_sum_filtermap_ints() {
845845
let seq_sum_evens = a
846846
.iter()
847847
.filter_map(|&x| if (x & 1) == 0 { Some(x as f32) } else { None })
848-
.fold(0.0, |a, b| a + b);
848+
.sum();
849849
assert_eq!(par_sum_evens, seq_sum_evens);
850850
}
851851

0 commit comments

Comments
 (0)