diff --git a/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_infer_async_request_thread_safe_default.hpp b/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_infer_async_request_thread_safe_default.hpp index a0a0a89bfc2780..d7b2da1d01d599 100644 --- a/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_infer_async_request_thread_safe_default.hpp +++ b/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_infer_async_request_thread_safe_default.hpp @@ -45,7 +45,9 @@ class AsyncInferRequestThreadSafeDefault : public AsyncInferRequestThreadSafeInt using Futures = std::vector>; using Promise = std::shared_ptr>; enum Stage_e : std::uint8_t { executor, task }; - struct DisableCallbackGuard{ + InferRequestInternal::Ptr _syncRequest; + + struct DisableCallbackGuard { explicit DisableCallbackGuard(AtomicCallback& callback) : _callbackRef(callback), _callback(callback.exchange(nullptr)) {} ~DisableCallbackGuard() { @@ -54,7 +56,12 @@ class AsyncInferRequestThreadSafeDefault : public AsyncInferRequestThreadSafeInt AtomicCallback& _callbackRef; IInferRequest::CompletionCallback _callback; }; - InferRequestInternal::Ptr _syncRequest; + + struct ImmediateStreamsExecutor : public InferenceEngine::ITaskExecutor { + explicit ImmediateStreamsExecutor(const IStreamsExecutor::Ptr& streamsExecutor) : _streamsExecutor{streamsExecutor} {} + void run(InferenceEngine::Task task) override {_streamsExecutor->Execute(std::move(task));} + IStreamsExecutor::Ptr _streamsExecutor; + }; public: /** @@ -78,14 +85,9 @@ class AsyncInferRequestThreadSafeDefault : public AsyncInferRequestThreadSafeInt _requestExecutor {taskExecutor}, _callbackExecutor {callbackExecutor}, _pipeline {{taskExecutor, [this] {_syncRequest->Infer();}}}, - _syncPipeline{{std::make_shared(), [this] {_syncRequest->Infer();}}} { + _syncPipeline {{std::make_shared(), [this] {_syncRequest->Infer();}}} { auto streamsExecutor = std::dynamic_pointer_cast(taskExecutor); if (streamsExecutor != nullptr) { - struct ImmediateStreamsExecutor : public InferenceEngine::ITaskExecutor { - explicit ImmediateStreamsExecutor(const IStreamsExecutor::Ptr& streamsExecutor) : _streamsExecutor{streamsExecutor} {} - void run(InferenceEngine::Task task) override {_streamsExecutor->Execute(std::move(task));} - IStreamsExecutor::Ptr _streamsExecutor; - }; _syncPipeline = {{std::make_shared(std::move(streamsExecutor)), [this] {_syncRequest->Infer();}}}; } }