Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d38dbbfcc9a1
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: db4fcae052d1
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Feb 14, 2019

  1. Copy the full SHA
    9319ccf View commit details

Commits on Feb 15, 2019

  1. Merge pull request #2076 from pleroy/RacyBundle

    Fix a race condition in the Bundle
    pleroy authored Feb 15, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    db4fcae View commit details
Showing with 7 additions and 5 deletions.
  1. +7 −5 base/bundle.cpp
12 changes: 7 additions & 5 deletions base/bundle.cpp
Original file line number Diff line number Diff line change
@@ -56,11 +56,13 @@ void Bundle::Toil(Task const& task) {
status_.Update(status);
}

// No locking unless this is the last task and we are joining. This
// avoids contention during joining. Note that if |joining_| is true we know
// that |number_of_active_workers_| cannot increase.
--number_of_active_workers_;
if (joining_ && number_of_active_workers_ == 0) {
// No locking, so as to avoid contention during joining. Note that if
// |joining_| is true we know that |number_of_active_workers_| cannot
// increase. Reading |number_of_active_workers_| independently from the
// decrement would be incorrect as we must ensure that exactly one thread sees
// that counter dropping to zero.
int const number_of_active_workers = --number_of_active_workers_;
if (joining_ && number_of_active_workers == 0) {
all_done_.Notify();
}
}