Commit a6f5812
committed
[runtime] Create a trait for briding async and parallel code
When calling into code doing heavy computation using a Strategy, you want
to avoid blocking the tokio thread on waiting for the computation. Instead,
you want the waiting to be async, so that other tasks can use the thread
while you wait for the computation to finish in the rayon thread pool.
To facilitate this pattern, a new capability, Strategist, is added to
to the runtime Context. This takes in a synchronous closure, which needs
a strategy to do parallel computation. Runtimes implement this correctly,
by using, e.g. a oneshot channel to asynchronously wait on the rayon result,
or using the tokio blocking pool for a sequential strategy.
To use this change throughout the code base, places where a Strategy was
stored have been replaced with using the context instead.1 parent c6a805b commit a6f5812
33 files changed
Lines changed: 820 additions & 521 deletions
File tree
- consensus
- fuzz/src
- src
- aggregation
- marshal
- coding
- shards
- core
- mocks
- standard
- ordered_broadcast
- simplex
- actors
- batcher
- resolver
- examples
- bridge/src/bin
- log/src
- p2p/src/utils
- parallel/src
- runtime/src
- tokio
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
36 | | - | |
37 | 36 | | |
38 | 37 | | |
39 | 38 | | |
| |||
402 | 401 | | |
403 | 402 | | |
404 | 403 | | |
405 | | - | |
406 | 404 | | |
407 | 405 | | |
408 | 406 | | |
| |||
636 | 634 | | |
637 | 635 | | |
638 | 636 | | |
639 | | - | |
640 | 637 | | |
641 | 638 | | |
642 | 639 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| |||
21 | 20 | | |
22 | 21 | | |
23 | 22 | | |
24 | | - | |
25 | 23 | | |
26 | 24 | | |
27 | 25 | | |
| |||
79 | 77 | | |
80 | 78 | | |
81 | 79 | | |
82 | | - | |
83 | | - | |
84 | | - | |
85 | 80 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
31 | | - | |
| 30 | + | |
32 | 31 | | |
33 | 32 | | |
34 | 33 | | |
| |||
71 | 70 | | |
72 | 71 | | |
73 | 72 | | |
74 | | - | |
| 73 | + | |
75 | 74 | | |
76 | 75 | | |
77 | 76 | | |
78 | 77 | | |
79 | 78 | | |
80 | 79 | | |
81 | | - | |
82 | 80 | | |
83 | 81 | | |
84 | 82 | | |
| |||
87 | 85 | | |
88 | 86 | | |
89 | 87 | | |
90 | | - | |
91 | 88 | | |
92 | 89 | | |
93 | 90 | | |
| |||
154 | 151 | | |
155 | 152 | | |
156 | 153 | | |
157 | | - | |
| 154 | + | |
158 | 155 | | |
159 | 156 | | |
160 | 157 | | |
161 | 158 | | |
162 | 159 | | |
163 | 160 | | |
164 | | - | |
165 | | - | |
| 161 | + | |
166 | 162 | | |
167 | 163 | | |
168 | | - | |
| 164 | + | |
169 | 165 | | |
170 | 166 | | |
171 | 167 | | |
| |||
176 | 172 | | |
177 | 173 | | |
178 | 174 | | |
179 | | - | |
180 | 175 | | |
181 | 176 | | |
182 | 177 | | |
| |||
385 | 380 | | |
386 | 381 | | |
387 | 382 | | |
388 | | - | |
| 383 | + | |
389 | 384 | | |
390 | 385 | | |
391 | 386 | | |
| |||
530 | 525 | | |
531 | 526 | | |
532 | 527 | | |
| 528 | + | |
533 | 529 | | |
534 | 530 | | |
535 | | - | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
536 | 538 | | |
537 | 539 | | |
538 | 540 | | |
| |||
613 | 615 | | |
614 | 616 | | |
615 | 617 | | |
616 | | - | |
| 618 | + | |
617 | 619 | | |
618 | 620 | | |
619 | 621 | | |
| |||
679 | 681 | | |
680 | 682 | | |
681 | 683 | | |
682 | | - | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
683 | 691 | | |
684 | 692 | | |
685 | 693 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
102 | 101 | | |
103 | 102 | | |
104 | 103 | | |
| |||
253 | 252 | | |
254 | 253 | | |
255 | 254 | | |
256 | | - | |
257 | 255 | | |
258 | 256 | | |
259 | 257 | | |
| |||
502 | 500 | | |
503 | 501 | | |
504 | 502 | | |
505 | | - | |
506 | 503 | | |
507 | 504 | | |
508 | 505 | | |
| |||
656 | 653 | | |
657 | 654 | | |
658 | 655 | | |
659 | | - | |
660 | 656 | | |
661 | 657 | | |
662 | 658 | | |
| |||
743 | 739 | | |
744 | 740 | | |
745 | 741 | | |
746 | | - | |
747 | 742 | | |
748 | 743 | | |
749 | 744 | | |
| |||
1091 | 1086 | | |
1092 | 1087 | | |
1093 | 1088 | | |
1094 | | - | |
1095 | 1089 | | |
1096 | 1090 | | |
1097 | 1091 | | |
| |||
0 commit comments