plugin  0.1.0
requests_pool.h
1 /*
2 // Copyright (C) 2020-2024 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16 
17 #pragma once
18 
19 #include <stddef.h>
20 
21 #include <mutex>
22 #include <utility>
23 #include <vector>
24 
25 #include <openvino/openvino.hpp>
26 
29 class RequestsPool {
30 public:
31  RequestsPool(ov::CompiledModel& compiledModel, unsigned int size);
32  ~RequestsPool();
33 
38  ov::InferRequest getIdleRequest();
39 
43  void setRequestIdle(const ov::InferRequest& request);
44 
47  size_t getInUseRequestsCount();
48 
52 
58 
61  std::vector<ov::InferRequest> getInferRequestsList();
62 
63 private:
64  std::vector<std::pair<ov::InferRequest, bool>> requests;
65  size_t numRequestsInUse;
66  std::mutex mtx;
67 };
Definition: requests_pool.h:29
std::vector< ov::InferRequest > getInferRequestsList()
Definition: requests_pool.cpp:85
bool isIdleRequestAvailable()
Definition: requests_pool.cpp:69
void waitForTotalCompletion()
Definition: requests_pool.cpp:74
size_t getInUseRequestsCount()
Definition: requests_pool.cpp:64
void setRequestIdle(const ov::InferRequest &request)
Definition: requests_pool.cpp:53
ov::InferRequest getIdleRequest()
Definition: requests_pool.cpp:38