51#ifndef vtkThreadedTaskQueue_h
52#define vtkThreadedTaskQueue_h
56#include <condition_variable>
73template <
typename R,
typename... Args>
78 int buffer_size = -1,
int max_concurrent_tasks = -1);
115 std::unique_ptr<vtkThreadedTaskQueueInternals::TaskQueue<R>> Tasks;
116 std::unique_ptr<vtkThreadedTaskQueueInternals::ResultQueue<R>> Results;
119 std::unique_ptr<std::thread[]> Threads;
122template <
typename... Args>
127 int buffer_size = -1,
int max_concurrent_tasks = -1);
152 std::unique_ptr<vtkThreadedTaskQueueInternals::TaskQueue<void>> Tasks;
154 std::condition_variable ResultsCV;
155 std::mutex NextResultIdMutex;
156 std::atomic<std::uint64_t> NextResultId;
159 std::unique_ptr<std::thread[]> Threads;
162#include "vtkThreadedTaskQueue.txx"
void Push(Args &&... args)
Push arguments for the work.
void Flush()
Blocks till the queue becomes empty.
bool IsEmpty() const
Returns false if there's some result that may be popped right now or in the future.
vtkThreadedTaskQueue(std::function< void(Args...)> worker, bool strict_ordering=true, int buffer_size=-1, int max_concurrent_tasks=-1)
simple threaded task queue
bool Pop(R &result)
Pop the last result.
bool TryPop(R &result)
Attempt to pop without waiting.
vtkThreadedTaskQueue(std::function< R(Args...)> worker, bool strict_ordering=true, int buffer_size=-1, int max_concurrent_tasks=-1)
void Push(Args &&... args)
Push arguments for the work.
bool IsEmpty() const
Returns false if there's some result that may be popped right now or in the future.
void Flush()
Blocks till the queue becomes empty.