Skip to content

vtkThreadedCallbackQueue: new utility

vtkThreadedCallbackQueue is a new utility that allows the user to run functions in the background in a FIFO fashion. The user can set the number of threads to run.

This class slightly ressembles vtkThreadedTaskQueue. The main differences are that vtkThreadedCallbackQueue is a vtkObject and that the class itself is not templated, like vtkThreadedTaskQueue, which is templated on a std::function. vtkThreadedCallbackQueue is thus more flexible and the user can put any collection of functions.

Input functions are put inside a custom type templated over this function and its parameters. This custom type is polymorphic to a base type that is stored inside the queue. Threads can be spawned who will each try to empty the queue and run the stored function.

Controls to this queue (Start, Stop, SetNumberOfThreads) run asynchronously thanks to an internal controller (which is an instance of the threaded callback queue itself), and are thread-safe.

The main reason controls run asynchronously and are thread-safe is so changing the parameters of this queue in the ParaView settings don't block the GUI by waiting on some jobs to end.

Adresses paraview/paraview#21708 (closed)

Edited by Yohann Bearzi (Kitware)

Merge request reports