MCPcopy Create free account
hub / github.com/bdring/FluidNC / background_task

Method background_task

FluidNC/src/WebUI/WebClient.cpp:16–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14 TaskHandle_t WebClients::_background_task_handle = nullptr;
15
16 void WebClients::background_task(void* pvParameters) {
17 std::string cmd;
18 while (true) {
19 WebClient* webClient;
20 if (xQueueReceive(_background_task_queue, &webClient, portMAX_DELAY) == pdTRUE) {
21 webClient->xBufferLock.lock();
22 if (webClient->cmds.size() > 0) {
23 cmd = webClient->cmds.front();
24 webClient->cmds.pop_front();
25 webClient->xBufferLock.unlock();
26 // TODO: check error result and see if we can do anything...
27 settings_execute_line(cmd.c_str(), *webClient, AuthenticationLevel::LEVEL_ADMIN);
28 // Should not call detach, since we still need to send the remaining buffer, so we should not free and clear yet.
29 webClient->xBufferLock.lock();
30 webClient->done = true;
31 webClient->xBufferLock.unlock();
32 } else {
33 webClient->xBufferLock.unlock();
34 }
35 } else
36 delay(1); // This should never happen if portMAX_DELAY is trully infinite
37 }
38 }
39
40 WebClient::WebClient() : Channel("webclient") {
41 if (WebClients::_background_task_queue == nullptr) // If we are the first instanciation ever, create the event queue

Callers

nothing calls this directly

Calls 6

settings_execute_lineFunction · 0.85
lockMethod · 0.80
unlockMethod · 0.80
c_strMethod · 0.80
delayFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected