diff options
author | Tor Brede Vekterli <vekterli@yahooinc.com> | 2022-05-16 17:44:33 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-16 17:44:33 +0200 |
commit | e2f707a511fd320d41d6ab33fb75ebbc4b4c54fe (patch) | |
tree | baaef3f20483512f38f73a174d674c0d41d76c32 | |
parent | 4bb588d36eab746d4bc5d210f869b116790ff437 (diff) | |
parent | 1649af608189b0b920afb649ff012a00ecdc9f9a (diff) |
Merge pull request #22625 from vespa-engine/vekterli/ensure-threads-vector-is-visible-to-stripe-threads
Ensure stripe pool threads vector is fully visible to all started stripes
-rw-r--r-- | storage/src/vespa/storage/distributor/distributor_stripe_pool.cpp | 1 | ||||
-rw-r--r-- | storage/src/vespa/storage/distributor/distributor_stripe_thread.cpp | 4 |
2 files changed, 3 insertions, 2 deletions
diff --git a/storage/src/vespa/storage/distributor/distributor_stripe_pool.cpp b/storage/src/vespa/storage/distributor/distributor_stripe_pool.cpp index 8b172743d27..30d13e4eb1a 100644 --- a/storage/src/vespa/storage/distributor/distributor_stripe_pool.cpp +++ b/storage/src/vespa/storage/distributor/distributor_stripe_pool.cpp @@ -117,6 +117,7 @@ void DistributorStripePool::start(const std::vector<TickableStripe*>& stripes) { if (_single_threaded_test_mode) { return; // We want all the control structures in place, but none of the actual OS threads. } + std::unique_lock lock(_mutex); // Ensure _threads is visible to all started threads for (auto& s : _stripes) { _threads.emplace_back(_thread_pool.NewThread(s.get())); } diff --git a/storage/src/vespa/storage/distributor/distributor_stripe_thread.cpp b/storage/src/vespa/storage/distributor/distributor_stripe_thread.cpp index ae5445da620..8f37dbbbf5d 100644 --- a/storage/src/vespa/storage/distributor/distributor_stripe_thread.cpp +++ b/storage/src/vespa/storage/distributor/distributor_stripe_thread.cpp @@ -47,7 +47,7 @@ void DistributorStripeThread::signal_wants_park() noexcept { assert(!should_park_relaxed()); _should_park.store(true, std::memory_order_relaxed); if (_waiting_for_event) { - _event_cond.notify_one(); // TODO after unlock? + _event_cond.notify_one(); } } @@ -55,7 +55,7 @@ void DistributorStripeThread::unpark_thread() noexcept { std::lock_guard lock(_mutex); assert(should_park_relaxed()); _should_park.store(false, std::memory_order_relaxed); - _park_cond.notify_one(); // TODO after unlock? + _park_cond.notify_one(); } void DistributorStripeThread::wait_until_event_notified_or_timed_out() noexcept { |