1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
10 #include <cpp_interfaces/ie_task.hpp>
11 #include "cpp_interfaces/interface/ie_iinfer_async_request_internal.hpp"
12 #include "cpp_interfaces/impl/ie_infer_request_internal.hpp"
14 namespace InferenceEngine {
17 * @brief minimum API to be implemented by plugin, which is used in InferRequestBase forwarding mechanism
19 class AsyncInferRequestInternal : public IAsyncInferRequestInternal, public InferRequestInternal {
21 typedef std::shared_ptr<AsyncInferRequestInternal> Ptr;
23 explicit AsyncInferRequestInternal(InputsDataMap networkInputs, OutputsDataMap networkOutputs)
24 : InferRequestInternal(networkInputs, networkOutputs), _callback(nullptr) {}
26 void SetCompletionCallback(InferenceEngine::IInferRequest::CompletionCallback callback) override {
30 void GetUserData(void **data) override {
31 if (data == nullptr) THROW_IE_EXCEPTION << NOT_ALLOCATED_str;
35 void SetUserData(void *data) override {
40 * @brief Set weak pointer to the corresponding public interface: IInferRequest. This allow to pass it to
41 * IInferRequest::CompletionCallback
42 * @param ptr - weak pointer to InferRequestBase
44 void SetPublicInterfacePtr(IInferRequest::Ptr ptr) {
45 _publicInterface = ptr;
49 * @brief The minimal infer function to be implemented by plugins. It starts inference of specified input(s) in asynchronous mode
50 * @note: It returns immediately. Inference starts also immediately.
52 virtual void StartAsyncImpl() = 0;
54 void StartAsync() override {
60 IInferRequest::WeakPtr _publicInterface;
61 InferenceEngine::IInferRequest::CompletionCallback _callback;
65 } // namespace InferenceEngine