MCPcopy Create free account
hub / github.com/FastFlowLM/FastFlowLM / process_next_npu_request

Method process_next_npu_request

src/server/server.cpp:593–625  ·  view source on GitHub ↗

@brief process_next_npu_request Handles one queued NPU task at a time

Source from the content-addressed store, hash-verified

591
592///@brief process_next_npu_request Handles one queued NPU task at a time
593void WebServer::process_next_npu_request() {
594 {
595 std::lock_guard<std::mutex> lock(npu_queue_mutex_);
596 if (npu_request_queue_.empty()) {
597 NPUAccessManager::release_npu_access();
598 return; // Queue is empty, NPU is free
599 }
600 }
601
602 // NPU cooldown before running the next queued task.
603 constexpr auto npu_cooldown = std::chrono::milliseconds(333);
604 std::this_thread::sleep_for(npu_cooldown);
605
606 std::function<void()> task;
607 size_t remaining = 0;
608 {
609 std::lock_guard<std::mutex> lock(npu_queue_mutex_);
610 if (npu_request_queue_.empty()) {
611 NPUAccessManager::release_npu_access();
612 return;
613 }
614
615 task = npu_request_queue_.front();
616 npu_request_queue_.pop();
617 remaining = npu_request_queue_.size();
618 }
619
620 header_print("🟡 ", "Dequeuing NPU request (" + std::to_string(remaining) + " remaining)...");
621
622 // Post the task to be executed by the io_context
623 net::post(ioc, task);
624
625}
626
627///@brief handle request
628///@param req the request

Callers 1

handle_requestMethod · 0.95

Calls 4

popMethod · 0.80
to_stringFunction · 0.50
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected