Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / src / inference_engine / cpp_interfaces / ie_task_with_stages.hpp
1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 #pragma once
6
7 #include <vector>
8 #include <mutex>
9 #include <memory>
10 #include <condition_variable>
11 #include <thread>
12 #include <queue>
13 #include "ie_api.h"
14 #include "details/ie_exception.hpp"
15 #include "cpp_interfaces/exception2status.hpp"
16 #include "cpp_interfaces/ie_task.hpp"
17 #include "ie_task_synchronizer.hpp"
18
19 namespace InferenceEngine {
20
21 /**
22  * This class represents a task which can have several stages
23  * and can be migrated from one task executor to another one
24  * between stages. This is required to continue execution of the
25  * task with special lock for device
26  */
27 class INFERENCE_ENGINE_API_CLASS(StagedTask) : public Task {
28 public:
29     typedef std::shared_ptr<StagedTask> Ptr;
30
31     StagedTask(std::function<void()> function, size_t stages);
32
33     StagedTask();
34
35     Status runNoThrowNoBusyCheck() noexcept override;
36
37     void resetStages();
38
39     void stageDone();
40
41     size_t getStage();
42
43 private:
44     size_t _stages;
45     size_t _stage;
46     std::mutex _runMutex;
47 };
48
49
50 }  // namespace InferenceEngine