carb::tasking::ThreadPoolWrapper¶
Defined in carb/tasking/ThreadPoolUtils.h
-
class
carb::tasking
::
ThreadPoolWrapper
¶ Helper class for using IThreadPool API.
Public Functions
-
inline
ThreadPoolWrapper
(IThreadPool *poolInterface, size_t workerCount = 0)¶ Constructor.
- Parameters
poolInterface – The acquired IThreadPool interface.
workerCount – (optional) The number of worker threads to create. If 0 (default) is specified, the value returned from IThreadPool::getDefaultWorkerCount() is used.
-
inline size_t
getWorkerCount
() const¶ Returns the number of worker threads in the threaad pool.
- Returns
The number of worker threads.
-
template<class
Callable
, class ...Args
>
inline autoenqueueJob
(Callable &&task, Args&&... args)¶ Enqueues a Callable to run on a worker thread.
- Parameters
task – The callable object. May be a lambda, [member] function, functor, etc.
args – Optional std::bind-style arguments to pass to the callable object.
- Returns
A std::future based on the return-type of the callable object. If enqueuing failed,
valid()
on the returned future will be false.
-
inline size_t
getCurrentlyRunningJobCount
() const¶ Returns the number of jobs currently enqueued or executing in the ThreadPool.
enqueueJob() increments this value and the value is decremented as jobs finish.
Note
This value changes by other threads and cannot be read atomically.
- Returns
The number of jobs currently executing in the ThreadPool.
-
inline void
waitUntilFinished
() const¶ Blocks the calling thread until all enqueued tasks have completed.
-
inline bool
isValid
() const¶ Returns true if the underlying ThreadPool is valid.
- Returns
true
if the underlying ThreadPool is valid;false
otherwise.
-
inline
~ThreadPoolWrapper
()¶ Destructor.
-
inline