1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
11 #include <condition_variable>
15 #include "details/ie_exception.hpp"
16 #include "cpp_interfaces/ie_task_synchronizer.hpp"
17 #include "cpp_interfaces/ie_task.hpp"
18 #include "cpp_interfaces/exception2status.hpp"
19 #include "cpp_interfaces/ie_itask_executor.hpp"
21 namespace InferenceEngine {
23 class INFERENCE_ENGINE_API_CLASS(TaskExecutor) : public ITaskExecutor {
25 typedef std::shared_ptr<TaskExecutor> Ptr;
27 TaskExecutor(std::string name = "Default");
32 * @brief Add task for execution and notify working thread about new task to start.
33 * @note can be called from multiple threads - tasks will be added to the queue and executed one-by-one in FIFO mode.
34 * @param task - shared pointer to the task to start
35 * @return true if succeed to add task, otherwise - false
37 bool startTask(Task::Ptr task) override;
40 std::shared_ptr<std::thread> _thread;
41 std::mutex _queueMutex;
42 std::condition_variable _queueCondVar;
43 std::queue<Task::Ptr> _taskQueue;
48 } // namespace InferenceEngine