diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2021-10-30 19:33:09 +0300 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2021-11-03 11:26:49 +0200 |
commit | c43aa623435a277a692dbde784e8a7146f5573e9 (patch) | |
tree | 5eaeff437fb26d5fcbe632e476093b365a6b72e0 /src/checkqueue.h | |
parent | 7efc628539573af4b4a76d93b853cc46e9e52eae (diff) |
Avoid excessive lock contention in CCheckQueue::Add
Diffstat (limited to 'src/checkqueue.h')
-rw-r--r-- | src/checkqueue.h | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/checkqueue.h b/src/checkqueue.h index 7c20e2013c..d926326a95 100644 --- a/src/checkqueue.h +++ b/src/checkqueue.h @@ -167,12 +167,15 @@ public: //! Add a batch of checks to the queue void Add(std::vector<T>& vChecks) { - LOCK(m_mutex); - for (T& check : vChecks) { - queue.push_back(T()); - check.swap(queue.back()); + { + LOCK(m_mutex); + for (T& check : vChecks) { + queue.emplace_back(); + check.swap(queue.back()); + } + nTodo += vChecks.size(); } - nTodo += vChecks.size(); + if (vChecks.size() == 1) m_worker_cv.notify_one(); else if (vChecks.size() > 1) |