diff --git a/src/engine/naive_engine.cc b/src/engine/naive_engine.cc index 92b38a8ea368..a7a9e992db7b 100644 --- a/src/engine/naive_engine.cc +++ b/src/engine/naive_engine.cc @@ -155,9 +155,9 @@ class NaiveEngine final : public Engine { int priority = 0, const char* opr_name = nullptr, bool wait = false) override { + bool req_completed = false; CallbackOnComplete callback = CreateCallback( - NaiveEngine::OnComplete, nullptr); - this->req_completed_ = false; + NaiveEngine::OnComplete, &req_completed); profiler::Profiler *profiler = profiler::Profiler::Get(); auto opr_deleter = [this](NaiveOpr* p) { this->DeleteOperator(p); @@ -202,7 +202,7 @@ class NaiveEngine final : public Engine { for (auto var : mutable_vars) { ++var->version_; } - CHECK(this->req_completed_) + CHECK(req_completed) << "NaiveEngine only support synchronize Push so far"; if (profiling) { opr->opr_profile->stop(); @@ -235,10 +235,9 @@ class NaiveEngine final : public Engine { // callback to oncomplete static void OnComplete(Engine *engine, void *param, const dmlc::Error* error) { - static_cast(engine)->req_completed_ = true; + bool *req_completed = static_cast(param); + *req_completed = true; } - // whether action is completed - bool req_completed_; /*! \brief whether it is during shutdown phase*/ std::atomic shutdown_phase_{false}; // CPU stream @@ -261,5 +260,6 @@ class NaiveEngine final : public Engine { Engine *CreateNaiveEngine() { return new NaiveEngine(); } + } // namespace engine } // namespace mxnet