MCPcopy Create free account
hub / github.com/PaddlePaddle/Serving / ThreadLoop

Method ThreadLoop

core/predictor/framework/request_cache.cpp:180–202  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178}
179
180void RequestCache::ThreadLoop() {
181 std::queue<std::pair<uint64_t, std::shared_ptr<Response>>> exec_task_queue;
182 for (;;) {
183 {
184 std::unique_lock<std::mutex> lock(queue_mutex_);
185 condition_.wait(
186 lock, [this]() { return this->bstop_ || this->task_queue_.size(); });
187
188 if (!task_queue_.size()) {
189 if (bstop_) {
190 return;
191 }
192 continue;
193 }
194 swap(exec_task_queue, task_queue_);
195 }
196 while (!exec_task_queue.empty()) {
197 auto [key, res_ptr] = exec_task_queue.front();
198 exec_task_queue.pop();
199 PutImpl(*res_ptr, key);
200 }
201 }
202}
203
204int RequestCache::AddTask(uint64_t key, const Response& res) {
205 std::unique_lock<std::mutex> lock(queue_mutex_);

Callers 1

RequestCacheMethod · 0.95

Calls 4

waitMethod · 0.80
emptyMethod · 0.80
sizeMethod · 0.45
frontMethod · 0.45

Tested by

no test coverage detected