transwarp
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
Classes | Public Member Functions | List of all members
transwarp::graph_pool< Graph > Class Template Reference

A graph pool that allows running multiple instances of the same graph in parallel. Graph must be a sub-class of transwarp::graph. More...

#include <transwarp.h>

Public Member Functions

 graph_pool (std::function< std::shared_ptr< Graph >()> generator, std::size_t minimum_size, std::size_t maximum_size)
 Constructs a graph pool by passing a generator to create a new graph and a minimum and maximum size of the pool. The minimum size is used as the initial size of the pool. Graph should be a subclass of transwarp::graph.
 
 graph_pool (const graph_pool &)=delete
 
graph_pooloperator= (const graph_pool &)=delete
 
 graph_pool (graph_pool &&)=delete
 
graph_pooloperator= (graph_pool &&)=delete
 
std::shared_ptr< Graph > next_idle_graph (bool maybe_resize=true)
 Returns the next idle graph. If there are no idle graphs then it will attempt to double the pool size. If that fails then it will return a nullptr. On successful retrieval of an idle graph the function will mark that graph as busy.
 
std::shared_ptr< Graph > wait_for_next_idle_graph (bool maybe_resize=true)
 Just like next_idle_graph() but waits for a graph to become available. The returned graph will always be a valid pointer.
 
std::size_t size () const
 Returns the current total size of the pool (sum of idle and busy graphs)
 
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 graphs in the pool.
 
std::size_t busy_count () const
 Returns the number of busy graphs in the pool.
 
void resize (std::size_t new_size)
 Resizes the graph pool to the given new size if possible.
 
void reclaim ()
 Reclaims finished graphs by marking them as idle again.
 

Detailed Description

template<typename Graph>
class transwarp::graph_pool< Graph >

A graph pool that allows running multiple instances of the same graph in parallel. Graph must be a sub-class of transwarp::graph.


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