Kagome
Polkadot Runtime Engine in C++17
tools::containers::ObjectsCache< T, Alloc > Struct Template Reference

#include <objects_cache.hpp>

Inheritance diagram for tools::containers::ObjectsCache< T, Alloc >:
Collaboration diagram for tools::containers::ObjectsCache< T, Alloc >:

Public Types

using Type = T
 
using ObjectPtr = std::shared_ptr< Type >
 

Public Member Functions

ObjectsCacheoperator= (const ObjectsCache &)=delete
 
 ObjectsCache (const ObjectsCache &)=delete
 
ObjectsCacheoperator= (ObjectsCache &&)=delete
 
 ObjectsCache (ObjectsCache &&)=delete
 
 ObjectsCache ()=default
 
 ObjectsCache (Alloc &alloc)
 
virtual ~ObjectsCache ()
 
TypegetCachedObject ()
 
void setCachedObject (Type *const ptr)
 
ObjectPtr getSharedCachedObject ()
 

Private Types

using ObjectsArray = std::vector< Type * >
 

Private Member Functions

TypegetRawPtr ()
 
void setRawPtr (Type *const ptr)
 

Private Attributes

Alloc allocator_
 
std::mutex cache_blocker_
 
ObjectsArray cache_
 

Detailed Description

template<typename T, typename Alloc = ObjsCacheDefAlloc<T>>
struct tools::containers::ObjectsCache< T, Alloc >

Single type cache container. Contains the set of objects to be cached.

Template Parameters
Tis the type ob objects to be contained.
Allocis the allocator type
See also
ObjsCacheDefAlloc

Definition at line 39 of file objects_cache.hpp.

Member Typedef Documentation

template<typename T, typename Alloc = ObjsCacheDefAlloc<T>>
using tools::containers::ObjectsCache< T, Alloc >::ObjectPtr = std::shared_ptr<Type>

Definition at line 44 of file objects_cache.hpp.

template<typename T, typename Alloc = ObjsCacheDefAlloc<T>>
using tools::containers::ObjectsCache< T, Alloc >::ObjectsArray = std::vector<Type *>
private

Definition at line 88 of file objects_cache.hpp.

template<typename T, typename Alloc = ObjsCacheDefAlloc<T>>
using tools::containers::ObjectsCache< T, Alloc >::Type = T

Definition at line 43 of file objects_cache.hpp.

Constructor & Destructor Documentation

template<typename T, typename Alloc = ObjsCacheDefAlloc<T>>
tools::containers::ObjectsCache< T, Alloc >::ObjectsCache ( const ObjectsCache< T, Alloc > &  )
delete
template<typename T, typename Alloc = ObjsCacheDefAlloc<T>>
tools::containers::ObjectsCache< T, Alloc >::ObjectsCache ( ObjectsCache< T, Alloc > &&  )
delete
template<typename T, typename Alloc = ObjsCacheDefAlloc<T>>
tools::containers::ObjectsCache< T, Alloc >::ObjectsCache ( )
default
template<typename T, typename Alloc = ObjsCacheDefAlloc<T>>
tools::containers::ObjectsCache< T, Alloc >::ObjectsCache ( Alloc &  alloc)
inline

Definition at line 53 of file objects_cache.hpp.

template<typename T, typename Alloc = ObjsCacheDefAlloc<T>>
virtual tools::containers::ObjectsCache< T, Alloc >::~ObjectsCache ( )
inlinevirtual

Destroy cached objects.

Definition at line 58 of file objects_cache.hpp.

Member Function Documentation

template<typename T, typename Alloc = ObjsCacheDefAlloc<T>>
Type* tools::containers::ObjectsCache< T, Alloc >::getCachedObject ( )
inline

Extracts raw pointer to the object from the cache.

Returns
ptr to the object

Definition at line 68 of file objects_cache.hpp.

template<typename T, typename Alloc = ObjsCacheDefAlloc<T>>
Type* tools::containers::ObjectsCache< T, Alloc >::getRawPtr ( )
inlineprivate

Definition at line 94 of file objects_cache.hpp.

template<typename T, typename Alloc = ObjsCacheDefAlloc<T>>
ObjectPtr tools::containers::ObjectsCache< T, Alloc >::getSharedCachedObject ( )
inline

Pops object from cache and returns a shared_ptr, contained this object.

Note
after shared_ptr destruction, object will return back to the cache.

Definition at line 83 of file objects_cache.hpp.

template<typename T, typename Alloc = ObjsCacheDefAlloc<T>>
ObjectsCache& tools::containers::ObjectsCache< T, Alloc >::operator= ( const ObjectsCache< T, Alloc > &  )
delete
template<typename T, typename Alloc = ObjsCacheDefAlloc<T>>
ObjectsCache& tools::containers::ObjectsCache< T, Alloc >::operator= ( ObjectsCache< T, Alloc > &&  )
delete
template<typename T, typename Alloc = ObjsCacheDefAlloc<T>>
void tools::containers::ObjectsCache< T, Alloc >::setCachedObject ( Type *const  ptr)
inline

Returns raw pointer to the object back to cache.

Definition at line 75 of file objects_cache.hpp.

template<typename T, typename Alloc = ObjsCacheDefAlloc<T>>
void tools::containers::ObjectsCache< T, Alloc >::setRawPtr ( Type *const  ptr)
inlineprivate

Definition at line 106 of file objects_cache.hpp.

Member Data Documentation

template<typename T, typename Alloc = ObjsCacheDefAlloc<T>>
Alloc tools::containers::ObjectsCache< T, Alloc >::allocator_
private

Definition at line 90 of file objects_cache.hpp.

template<typename T, typename Alloc = ObjsCacheDefAlloc<T>>
ObjectsArray tools::containers::ObjectsCache< T, Alloc >::cache_
private

Definition at line 92 of file objects_cache.hpp.

template<typename T, typename Alloc = ObjsCacheDefAlloc<T>>
std::mutex tools::containers::ObjectsCache< T, Alloc >::cache_blocker_
private

Definition at line 91 of file objects_cache.hpp.


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