transwarp
Classes | Public Member Functions | List of all members
transwarp::task_pool< ResultType > Class Template Reference

A task pool that allows running multiple instances of the same task in parallel. More...

#include <transwarp.h>

Public Member Functions

 task_pool (std::shared_ptr< transwarp::task< ResultType >> task, std::size_t minimum_size, std::size_t maximum_size)
 Constructs a task pool.
 
 task_pool (std::shared_ptr< transwarp::task< ResultType >> task)
 Constructs a task pool with reasonable defaults for minimum and maximum.
 
 task_pool (const task_pool &)=delete
 
task_pooloperator= (const task_pool &)=delete
 
 task_pool (task_pool &&)=delete
 
task_pooloperator= (task_pool &&)=delete
 
std::shared_ptr< transwarp::task< ResultType > > next_task (bool maybe_resize=true)
 Returns the next idle task. If there are no idle tasks then it will attempt to double the pool size. If that fails then it will return a nullptr. On successful retrieval of an idle task the function will mark that task as busy.
 
std::shared_ptr< transwarp::task< ResultType > > wait_for_next_task (bool maybe_resize=true)
 Just like next_task() but waits for a task to become available. The returned task will always be a valid pointer.
 
std::size_t size () const
 Returns the current total size of the pool (sum of idle and busy tasks)
 
std::size_t minimum_size () const
 Returns the minimum size of the pool.
 
std::size_t maximum_size () const
 Returns the maximum size of the pool.
 
std::size_t idle_count () const
 Returns the number of idle tasks in the pool.
 
std::size_t busy_count () const
 Returns the number of busy tasks in the pool.
 
void resize (std::size_t new_size)
 Resizes the task pool to the given new size if possible.
 
void reclaim ()
 Reclaims finished tasks by marking them as idle again.
 

Detailed Description

template<typename ResultType>
class transwarp::task_pool< ResultType >

A task pool that allows running multiple instances of the same task in parallel.


The documentation for this class was generated from the following file: