Changeset View
Changeset View
Standalone View
Standalone View
src/checkqueue.h
Show First 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | public: | ||||
//! Wait until execution finishes, and return whether all evaluations were | //! Wait until execution finishes, and return whether all evaluations were | ||||
//! successful. | //! successful. | ||||
bool Wait() { return Loop(true); } | bool Wait() { return Loop(true); } | ||||
//! 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) { | ||||
boost::unique_lock<boost::mutex> lock(mutex); | boost::unique_lock<boost::mutex> lock(mutex); | ||||
for (T &check : vChecks) { | for (T &check : vChecks) { | ||||
queue.push_back(T()); | queue.push_back(std::move(check)); | ||||
check.swap(queue.back()); | |||||
} | } | ||||
nTodo += vChecks.size(); | nTodo += vChecks.size(); | ||||
if (vChecks.size() == 1) | if (vChecks.size() == 1) { | ||||
condWorker.notify_one(); | condWorker.notify_one(); | ||||
else if (vChecks.size() > 1) | } else if (vChecks.size() > 1) { | ||||
condWorker.notify_all(); | condWorker.notify_all(); | ||||
} | } | ||||
} | |||||
~CCheckQueue() {} | ~CCheckQueue() {} | ||||
bool IsIdle() { | bool IsIdle() { | ||||
boost::unique_lock<boost::mutex> lock(mutex); | boost::unique_lock<boost::mutex> lock(mutex); | ||||
return (nTotal == nIdle && nTodo == 0 && fAllOk == true); | return (nTotal == nIdle && nTodo == 0 && fAllOk == true); | ||||
} | } | ||||
}; | }; | ||||
Show All 37 Lines |