Remote Call Framework 3.4
RCF::ObjectPool Class Reference

Manages a cache of objects of various types. More...

#include <ObjectPool.hpp>

Public Member Functions

template<typename T >
void enableCaching (std::size_t maxCount, std::function< void(T *)> clearFunc)
 
template<typename T >
void disableCaching ()
 Disables caching of objects of type T. More...
 
template<typename T >
void getObj (std::shared_ptr< T > &objPtr, bool alwaysCreate=true)
 

Detailed Description

Manages a cache of objects of various types.

Member Function Documentation

◆ enableCaching()

template<typename T >
void RCF::ObjectPool::enableCaching ( std::size_t  maxCount,
std::function< void(T *)>  clearFunc 
)

Enables caching of objects of type T. The cache will hold at most maxCount instances of objects of type T. clearFunc() will be called on each instance of type T which is passed in to the cache.

◆ disableCaching()

template<typename T >
void RCF::ObjectPool::disableCaching ( )

Disables caching of objects of type T.

◆ getObj()

template<typename T >
void RCF::ObjectPool::getObj ( std::shared_ptr< T > &  objPtr,
bool  alwaysCreate = true 
)

Returns an object of type T from the cache. The object is returned as a std::shared_ptr<T> and is equipped with a custom deleter, so that once the shared_ptr<T> goes out of scope, the object is automatically returned to the cache. If alwaysCreate is true, an object will be created if none is present in the cache.


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