dispenso
A library for task parallelism
 
Loading...
Searching...
No Matches
dispenso::ResourcePool< T > Class Template Reference

#include <resource_pool.h>

Public Member Functions

template<typename F >
 ResourcePool (size_t size, const F &init)
 
Resource< Tacquire ()
 
 ~ResourcePool ()
 

Friends

class Resource< T >
 

Detailed Description

template<typename T>
class dispenso::ResourcePool< T >

A pool of resources that can be accessed from multiple threads. This is akin to a set of resources and a semaphore ensuring enough resources exist.

Definition at line 75 of file resource_pool.h.

Constructor & Destructor Documentation

◆ ResourcePool()

template<typename T >
template<typename F >
dispenso::ResourcePool< T >::ResourcePool ( size_t  size,
const F init 
)
inline

Construct a ResourcePool.

Parameters
sizeThe number of T objects in the pool.
initA functor with signature T() which can be called to initialize the pool's resources.

Definition at line 85 of file resource_pool.h.

◆ ~ResourcePool()

template<typename T >
dispenso::ResourcePool< T >::~ResourcePool ( )
inline

Destruct the ResourcePool. The user must ensure that all resources are returned to the pool prior to destroying the pool.

Definition at line 122 of file resource_pool.h.

Member Function Documentation

◆ acquire()

template<typename T >
Resource< T > dispenso::ResourcePool< T >::acquire ( )
inline

Acquire a resource from the pool. This function may block until a resource becomes available.

Returns
a Resource-wrapped resource.

Definition at line 110 of file resource_pool.h.

Friends And Related Symbol Documentation

◆ Resource< T >

template<typename T >
friend class Resource< T >
friend

Definition at line 143 of file resource_pool.h.


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