0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-08 10:31:50 -05:00

Avoid excessive lock contention in CCheckQueue::Add

This commit is contained in:
Hennadii Stepanov 2021-10-30 19:33:09 +03:00
parent 7efc628539
commit c43aa62343
No known key found for this signature in database
GPG key ID: 410108112E7EA81F

View file

@ -166,13 +166,16 @@ public:
//! Add a batch of checks to the queue //! Add a batch of checks to the queue
void Add(std::vector<T>& vChecks) void Add(std::vector<T>& vChecks)
{
{ {
LOCK(m_mutex); LOCK(m_mutex);
for (T& check : vChecks) { for (T& check : vChecks) {
queue.push_back(T()); queue.emplace_back();
check.swap(queue.back()); check.swap(queue.back());
} }
nTodo += vChecks.size(); nTodo += vChecks.size();
}
if (vChecks.size() == 1) if (vChecks.size() == 1)
m_worker_cv.notify_one(); m_worker_cv.notify_one();
else if (vChecks.size() > 1) else if (vChecks.size() > 1)