diff options
author | Tor Egge <Tor.Egge@online.no> | 2022-05-06 13:25:01 +0200 |
---|---|---|
committer | Tor Egge <Tor.Egge@online.no> | 2022-05-06 13:25:01 +0200 |
commit | e11a1a9e34c0eabec5a01eea6b44aa14bb906ba4 (patch) | |
tree | bf667c37b81956b8ab3184360335f6c7eb3e1fc3 /searchcore | |
parent | 2451e3307bbd0e89473e70f50e73cff39e7a1786 (diff) |
Re-sample max threads in loop. Wake up waiters after applying new config.
Diffstat (limited to 'searchcore')
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/matching/querylimiter.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/matching/querylimiter.cpp b/searchcore/src/vespa/searchcore/proton/matching/querylimiter.cpp index 55078ad92a2..df656177cbc 100644 --- a/searchcore/src/vespa/searchcore/proton/matching/querylimiter.cpp +++ b/searchcore/src/vespa/searchcore/proton/matching/querylimiter.cpp @@ -19,8 +19,7 @@ void QueryLimiter::grabToken(const Doom & doom) { std::unique_lock<std::mutex> guard(_lock); - auto max_threads = get_max_threads(); - while ((max_threads > 0) && (_activeThreads >= max_threads) && !doom.hard_doom()) { + for (auto max_threads = get_max_threads(); (max_threads > 0) && (_activeThreads >= max_threads) && !doom.hard_doom(); max_threads = get_max_threads()) { vespalib::duration left = doom.hard_left(); if (left > vespalib::duration::zero()) { _cond.wait_for(guard, left); @@ -50,9 +49,11 @@ QueryLimiter::QueryLimiter() : void QueryLimiter::configure(int maxThreads, double coverage, uint32_t minHits) { + std::lock_guard<std::mutex> guard(_lock); _maxThreads.store(maxThreads, std::memory_order_relaxed); _coverage.store(coverage, std::memory_order_relaxed); _minHits.store(minHits, std::memory_order_relaxed); + _cond.notify_all(); } QueryLimiter::Token::UP |