Commit c86bc37
authored
Make GlobalContext Sync (#15967)
### What does this PR try to resolve?
By making `GlobalContext` `Sync`, it will become much easier to
parallelize parts of cargo. A concrete example is #15676.
It was my understanding from
#15934 (comment)
that this would be a welcome change by the cargo team.
#### Overview
In `GlobalContext` and structs used in its fields
- `RefCell`-s were replaced by either an `std::sync::Mutex` or an
`std::sync::RwLock`, depending on API needs
- `LazyCell`-s were replaced by a new `OnceLock` implementation backed
by `std::sync::OnceLock`, emulating unstable features needed by cargo
- Removed `LazyCell`/`OnceLock` from fields where the initialization
function is just a `Mutex<HashMap>::default()`
- added `util::context::tests::sync_context` test that does not compile
if `GlobalContext` is not `Sync`
### How to test and review this PR?
This PR should add no user-facing changes. Tests must pass and
benchmarks must report no changes.File tree
10 files changed
+211
-104
lines changed- src/cargo
- core
- sources/git
- util
- context
- toml
10 files changed
+211
-104
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
800 | 800 | | |
801 | 801 | | |
802 | 802 | | |
803 | | - | |
804 | | - | |
805 | | - | |
806 | | - | |
807 | | - | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
808 | 806 | | |
809 | 807 | | |
810 | 808 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| |||
432 | 432 | | |
433 | 433 | | |
434 | 434 | | |
435 | | - | |
| 435 | + | |
436 | 436 | | |
437 | 437 | | |
438 | 438 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2037 | 2037 | | |
2038 | 2038 | | |
2039 | 2039 | | |
2040 | | - | |
| 2040 | + | |
2041 | 2041 | | |
2042 | 2042 | | |
2043 | 2043 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1528 | 1528 | | |
1529 | 1529 | | |
1530 | 1530 | | |
1531 | | - | |
| 1531 | + | |
1532 | 1532 | | |
1533 | 1533 | | |
1534 | 1534 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
95 | 94 | | |
| 95 | + | |
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
| |||
435 | 435 | | |
436 | 436 | | |
437 | 437 | | |
438 | | - | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
439 | 443 | | |
440 | 444 | | |
441 | 445 | | |
| |||
472 | 476 | | |
473 | 477 | | |
474 | 478 | | |
475 | | - | |
| 479 | + | |
476 | 480 | | |
477 | 481 | | |
478 | 482 | | |
479 | 483 | | |
480 | 484 | | |
481 | 485 | | |
482 | | - | |
| 486 | + | |
483 | 487 | | |
484 | 488 | | |
485 | | - | |
| 489 | + | |
| 490 | + | |
486 | 491 | | |
487 | 492 | | |
488 | 493 | | |
489 | 494 | | |
490 | 495 | | |
491 | 496 | | |
492 | | - | |
| 497 | + | |
493 | 498 | | |
494 | 499 | | |
495 | 500 | | |
| |||
501 | 506 | | |
502 | 507 | | |
503 | 508 | | |
504 | | - | |
| 509 | + | |
505 | 510 | | |
506 | 511 | | |
507 | 512 | | |
| |||
519 | 524 | | |
520 | 525 | | |
521 | 526 | | |
522 | | - | |
| 527 | + | |
523 | 528 | | |
524 | 529 | | |
525 | 530 | | |
| |||
0 commit comments