MCPcopy Create free account
hub / github.com/Kitware/VTK / TestThreadedTaskQueue

Function TestThreadedTaskQueue

Parallel/Core/Testing/Cxx/TestThreadedTaskQueue.cxx:8–40  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6#include <chrono>
7#include <thread>
8int TestThreadedTaskQueue(int, char*[])
9{
10 vtkThreadedTaskQueue<double, int, double> queue(
11 [](int i, double v)
12 {
13 vtkLogF(INFO, "hey: %d, %f", i, v);
14 return i * v;
15 },
16 false, 2, 1);
17 queue.Push(1, 1.0);
18 queue.Push(2, 2.0);
19 queue.Push(3, 3.0);
20
21 while (!queue.IsEmpty())
22 {
23 double r;
24 if (queue.Pop(r))
25 {
26 vtkLogF(INFO, "result: %f", r);
27 }
28 else
29 {
30 vtkLogF(ERROR, "failed to pop!");
31 }
32 }
33
34 vtkThreadedTaskQueue<void, int> queue2([](int id) -> void { vtkLogF(INFO, "hi: %d", id); });
35 queue2.Push(0);
36 queue2.Push(1);
37 queue2.Push(2);
38 queue2.Flush();
39 return EXIT_SUCCESS;
40}

Callers

nothing calls this directly

Calls 4

PushMethod · 0.45
IsEmptyMethod · 0.45
PopMethod · 0.45
FlushMethod · 0.45

Tested by

no test coverage detected