hpp-pinocchio  4.9.1
Wrapping of the kinematic/dynamic chain Pinocchio for HPP.
hpp::pinocchio::Pool< T > Class Template Reference

Pool of objects. More...

#include <hpp/pinocchio/pool.hh>

Public Member Functions

T * acquire ()
 
void release (T *t)
 
bool available () const
 Returns true is at least one object is not locked. More...
 
std::size_t size () const
 
void clear ()
 Deletes all internal objects. More...
 
void push_back (T *t)
 
template<class InputIterator >
void push_back (InputIterator first, InputIterator last)
 
 ~Pool ()
 
 Pool ()
 Constructor. More...
 

Detailed Description

template<typename T>
class hpp::pinocchio::Pool< T >

Pool of objects.

Usage:

Pool<Foo> pool;
std::vector<Foo*> temporary_foos;
// Fill temporary_foos new objects.
// The ownership is passed to the pool.
pool.push_back (foo.begin(), foo.end());
Foo* foo = pool.acquire();
// Access to foo is thread safe.
pool.release(foo);

Constructor & Destructor Documentation

◆ ~Pool()

template<typename T>
hpp::pinocchio::Pool< T >::~Pool ( )
inline

Destructor Calls Pool::clear()

◆ Pool()

template<typename T>
hpp::pinocchio::Pool< T >::Pool ( )
inline

Constructor.

Member Function Documentation

◆ acquire()

template<typename T>
T* hpp::pinocchio::Pool< T >::acquire ( )
inline

Get an object from the pool. If the pool is empty, wait until one element becomes available.

◆ available()

template<typename T>
bool hpp::pinocchio::Pool< T >::available ( ) const
inline

Returns true is at least one object is not locked.

◆ clear()

template<typename T>
void hpp::pinocchio::Pool< T >::clear ( void  )
inline

Deletes all internal objects.

◆ push_back() [1/2]

template<typename T>
void hpp::pinocchio::Pool< T >::push_back ( T *  t)
inline

Adds an object to the pool The pool takes ownership of the object

◆ push_back() [2/2]

template<typename T>
template<class InputIterator >
void hpp::pinocchio::Pool< T >::push_back ( InputIterator  first,
InputIterator  last 
)
inline

Add objects to the pool The pool takes ownership of the object

◆ release()

template<typename T>
void hpp::pinocchio::Pool< T >::release ( T *  t)
inline

Release a previously acquired object.

Warning
There is no check that the object was actually one returned by Pool::acquire

◆ size()

template<typename T>
std::size_t hpp::pinocchio::Pool< T >::size ( ) const
inline

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