quickpool namespace
More...
|
template<class Function , class... Args> |
void | push (Function &&f, Args &&... args) |
| Free-standing functions (main API) More...
|
|
template<class Function , class... Args> |
auto | async (Function &&f, Args &&... args) -> std::future< decltype(f(args...))> |
| executes a job asynchronously the global thread pool. More...
|
|
void | wait () |
| waits for all jobs currently running on the global thread pool. Has no effect when not called from main thread.
|
|
bool | done () |
| checks whether all globel jobs are done.
|
|
void | set_active_threads (size_t threads) |
| sets the number of active worker threads in the global thread pool. More...
|
|
size_t | get_active_threads () |
| retrieves the number of active worker threads in the global thread pool.
|
|
template<class UnaryFunction > |
void | parallel_for (int begin, int end, UnaryFunction &&f) |
| computes an index-based parallel for loop. More...
|
|
template<class Items , class UnaryFunction > |
void | parallel_for_each (Items &items, UnaryFunction &&f) |
| computes a iterator-based parallel for loop. More...
|
|
◆ async()
template<class Function , class... Args>
auto quickpool::async |
( |
Function && |
f, |
|
|
Args &&... |
args |
|
) |
| -> std::future<decltype(f(args...))>
|
|
inline |
executes a job asynchronously the global thread pool.
- Parameters
-
f | a function. |
args | (optional) arguments passed to f . |
- Returns
- A
std::future
for the task. Call future.get()
to retrieve the results at a later point in time (blocking).
Definition at line 1032 of file quickpool.hpp.
◆ parallel_for()
template<class UnaryFunction >
void quickpool::parallel_for |
( |
int |
begin, |
|
|
int |
end, |
|
|
UnaryFunction && |
f |
|
) |
| |
|
inline |
computes an index-based parallel for loop.
Waits until all tasks have finished, unless called from a thread that didn't create the pool. If this is taken into account, parallel loops can be nested.
- Parameters
-
begin | first index of the loop. |
end | the loop runs in the range [begin, end) . |
f | a function taking int argument (the 'loop body'). |
Definition at line 1081 of file quickpool.hpp.
◆ parallel_for_each()
template<class Items , class UnaryFunction >
void quickpool::parallel_for_each |
( |
Items & |
items, |
|
|
UnaryFunction && |
f |
|
) |
| |
|
inline |
computes a iterator-based parallel for loop.
Waits until all tasks have finished, unless called from a thread that didn't create the pool. If this is taken into account, parallel loops can be nested.
- Parameters
-
items | an object allowing for std::begin() and std::end() . |
f | function to be applied as f(*it) for the iterator in the range [begin, end) (the 'loop body'). |
Definition at line 1098 of file quickpool.hpp.
◆ push()
template<class Function , class... Args>
void quickpool::push |
( |
Function && |
f, |
|
|
Args &&... |
args |
|
) |
| |
|
inline |
Free-standing functions (main API)
push a job to the global thread pool.
- Parameters
-
f | a function. |
args | (optional) arguments passed to f . |
Definition at line 1019 of file quickpool.hpp.
◆ set_active_threads()
void quickpool::set_active_threads |
( |
size_t |
threads | ) |
|
|
inline |
sets the number of active worker threads in the global thread pool.
- Parameters
-
threads | the number of worker threads. Has no effect when not called from main thread. |
Definition at line 1057 of file quickpool.hpp.