MCPcopy Create free account
hub / github.com/XpuOS/xsched / GetXQueues

Method GetXQueues

service/server/src/server.cpp:270–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

268}
269
270void Server::GetXQueues(const httplib::Request &, httplib::Response &res)
271{
272 static std::mutex query_mtx;
273 std::lock_guard<std::mutex> lock(query_mtx);
274
275 static StatusQuery query(true);
276 query.Reset();
277 query.status_.reserve(256);
278 query.processes_.reserve(256);
279
280 auto e = std::make_unique<XQueueQueryAllEvent>(&query);
281 XASSERT(self_chan_->Send(e->Data(), e->Size()), "cannot send XQueue query all event");
282 query.Wait();
283
284 Json::Value xqueues(Json::arrayValue);
285 for (const auto &xq : query.status_) {
286 Json::Value xqueue;
287 XQueueStatusToJson(xqueue, *xq);
288 xqueues.append(xqueue);
289 }
290
291 Json::Value processes(Json::arrayValue);
292 for (const auto &p : query.processes_) {
293 Json::Value process;
294 process["pid"] = (Json::Int)p->pid;
295 process["cmdline"] = p->cmdline;
296 processes.append(process);
297 }
298
299 Json::Value response(Json::objectValue);
300 response["xqueues"] = xqueues;
301 response["processes"] = processes;
302 res.set_content(Json::writeString(json_writer_, response).c_str(), "application/json");
303}
304
305void Server::PostXQueueConfig(const httplib::Request &req, httplib::Response &res, const httplib::ContentReader &)
306{

Callers

nothing calls this directly

Calls 4

ResetMethod · 0.45
DataMethod · 0.45
SizeMethod · 0.45
WaitMethod · 0.45

Tested by

no test coverage detected