@ -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()) {