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

Use Extend method

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