提交 201f79d0 编写于 作者: Y Yu Yang

Use Extend method

上级 dcf7bd2d
......@@ -178,10 +178,7 @@ void ThreadedSSAGraphExecutor::RunOp(
try {
VLOG(10) << op->Name() << " : " << op->DebugString();
op->Run(use_event_);
for (auto &each : op->outputs_) {
ready_var_q.Push(each);
}
ready_var_q.Extend(op->outputs_);
} catch (platform::EnforceNotMet ex) {
exception_.reset(new platform::EnforceNotMet(ex));
} catch (...) {
......
......@@ -35,6 +35,17 @@ class BlockingQueue {
cv_.notify_one();
}
template <typename U>
void Extend(const U &items) {
{
std::lock_guard<std::mutex> g(mutex_);
for (auto &item : items) {
q_.emplace_back(item);
}
}
cv_.notify_all();
}
T Pop() {
std::unique_lock<std::mutex> lock(mutex_);
while (q_.empty()) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册