-----------------------------------------------------------------------------
| 19 | { |
| 20 | //----------------------------------------------------------------------------- |
| 21 | void RunThreads(int nthreadsBegin, int nthreadsEnd) |
| 22 | { |
| 23 | vtkNew<vtkThreadedCallbackQueue> queue; |
| 24 | std::atomic_int count(0); |
| 25 | int N = 10000; |
| 26 | |
| 27 | // Spamming controls |
| 28 | for (int i = 0; i < 6; ++i) |
| 29 | { |
| 30 | queue->SetNumberOfThreads(nthreadsBegin); |
| 31 | queue->SetNumberOfThreads(nthreadsEnd); |
| 32 | } |
| 33 | |
| 34 | // We are testing if the queue can properly resize itself and doesn't have deadlocks |
| 35 | for (vtkIdType i = 0; i < N; ++i) |
| 36 | { |
| 37 | vtkSmartPointer<vtkIntArray> array = vtkSmartPointer<vtkIntArray>::New(); |
| 38 | queue->Push( |
| 39 | [&count](const int& n, const double&&, char, vtkIntArray* a1, vtkIntArray* a2) |
| 40 | { |
| 41 | a1->SetName(vtk::to_string(n).c_str()); |
| 42 | a2->SetName(vtk::to_string(n).c_str()); |
| 43 | ++count; |
| 44 | }, |
| 45 | i, 0, 'a', vtkNew<vtkIntArray>(), array); |
| 46 | } |
| 47 | |
| 48 | // If the jobs are not run, this test will do an infinite loop |
| 49 | while (count != N) |
| 50 | ; |
| 51 | |
| 52 | // Checking how the queue behaves when being destroyed. |
| 53 | queue->SetNumberOfThreads(nthreadsBegin); |
| 54 | queue->SetNumberOfThreads(nthreadsEnd); |
| 55 | } |
| 56 | |
| 57 | //============================================================================= |
| 58 | struct A |
no test coverage detected