MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / QueueJob

Method QueueJob

src/gui/jobqueue.cc:6–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4#include "jobqueue.h"
5
6void JobQueue::QueueJob(std::function<void(void)> f)
7{
8 _jobQueue.push_back(f);
9 if (!IsQueueRunning())
10 {
11 runOnWorkerThread(
12 [this]()
13 {
14 auto fail = [&]()
15 {
16 runOnUiThread(
17 [&]()
18 {
19 _jobQueue.clear();
20 OnQueueFailed();
21 });
22 };
23
24 for (;;)
25 {
26 std::function<void()> f;
27 runOnUiThread(
28 [&]()
29 {
30 if (!_jobQueue.empty())
31 {
32 f = _jobQueue.front();
33 _jobQueue.pop_front();
34 }
35 });
36 if (!f)
37 break;
38
39 try
40 {
41 f();
42 }
43 catch (const EmergencyStopException& e)
44 {
45 fail();
46 throw e;
47 }
48 catch (const ErrorException& e)
49 {
50 fail();
51 throw e;
52 }
53
54 runOnUiThread(
55 [&]()
56 {
57 OnQueueEmpty();
58 });
59 }
60 });
61 }
62}
63

Callers

nothing calls this directly

Calls 5

runOnWorkerThreadFunction · 0.85
runOnUiThreadFunction · 0.70
push_backMethod · 0.45
clearMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected