mutable
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | Friends
m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe > Struct Template Reference

The PODPool implements an implicitly garbage-collected set of pooled (or internalized) POD struct entities. More...

#include <Pool.hpp>

Inheritance diagram for m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >:
[legend]
Collaboration diagram for m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >:
[legend]

Public Types

using counter_type = std::conditional_t< ThreadSafe, std::atomic< uint32_t >, uint32_t >
 
using table_type = std::unordered_map< T, counter_type, Hash, KeyEqual >
 
using pooled_type = T
 
using proxy_type = Pooled< T, PODPool, false >
 
using proxy_optional_type = Pooled< T, PODPool, true >
 
using hasher = Hash
 
using key_equal = KeyEqual
 
using copy = Copy
 
using const_iterator = table_type::const_iterator
 

Public Member Functions

 PODPool ()=default
 
 PODPool (std::size_t initial_capacity)
 
virtual ~PODPool ()
 
std::size_t size () const
 Returns the number of elements in the pool.
 
const_iterator begin ()
 
const_iterator end ()
 
const_iterator cbegin () const
 
const_iterator cend () const
 
template<typename U >
proxy_type operator() (U &&u)
 Returns the pooled.
 

Static Public Attributes

static constexpr bool is_thread_safe = ThreadSafe
 

Private Member Functions

template<bool CanBeNone>
bool erase (const Pooled< T, PODPool, CanBeNone > &pooled)
 Erases the pooled entity from the pool.
 

Static Private Member Functions

template<bool CanBeNone>
static const TGet (const Pooled< T, PODPool, CanBeNone > &pooled)
 Returns a reference to the value referenced by.
 

Private Attributes

table_type table_
 
OptField< ThreadSafe, reader_writer_mutextable_mutex_
 

Friends

template<typename , typename , bool >
struct Pooled
 

Detailed Description

template<typename T, typename Hash = std::hash<T>, typename KeyEqual = std::equal_to<T>, typename Copy = std::identity, bool ThreadSafe = false>
struct m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >

The PODPool implements an implicitly garbage-collected set of pooled (or internalized) POD struct entities.

Definition at line 22 of file Pool.hpp.

Member Typedef Documentation

◆ const_iterator

template<typename T , typename Hash = std::hash<T>, typename KeyEqual = std::equal_to<T>, typename Copy = std::identity, bool ThreadSafe = false>
using m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::const_iterator = table_type::const_iterator

Definition at line 44 of file Pool.hpp.

◆ copy

template<typename T , typename Hash = std::hash<T>, typename KeyEqual = std::equal_to<T>, typename Copy = std::identity, bool ThreadSafe = false>
using m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::copy = Copy

Definition at line 31 of file Pool.hpp.

◆ counter_type

template<typename T , typename Hash = std::hash<T>, typename KeyEqual = std::equal_to<T>, typename Copy = std::identity, bool ThreadSafe = false>
using m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::counter_type = std::conditional_t<ThreadSafe, std::atomic<uint32_t>, uint32_t>

Definition at line 24 of file Pool.hpp.

◆ hasher

template<typename T , typename Hash = std::hash<T>, typename KeyEqual = std::equal_to<T>, typename Copy = std::identity, bool ThreadSafe = false>
using m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::hasher = Hash

Definition at line 29 of file Pool.hpp.

◆ key_equal

template<typename T , typename Hash = std::hash<T>, typename KeyEqual = std::equal_to<T>, typename Copy = std::identity, bool ThreadSafe = false>
using m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::key_equal = KeyEqual

Definition at line 30 of file Pool.hpp.

◆ pooled_type

template<typename T , typename Hash = std::hash<T>, typename KeyEqual = std::equal_to<T>, typename Copy = std::identity, bool ThreadSafe = false>
using m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::pooled_type = T

Definition at line 26 of file Pool.hpp.

◆ proxy_optional_type

template<typename T , typename Hash = std::hash<T>, typename KeyEqual = std::equal_to<T>, typename Copy = std::identity, bool ThreadSafe = false>
using m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::proxy_optional_type = Pooled<T, PODPool, true>

Definition at line 28 of file Pool.hpp.

◆ proxy_type

template<typename T , typename Hash = std::hash<T>, typename KeyEqual = std::equal_to<T>, typename Copy = std::identity, bool ThreadSafe = false>
using m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::proxy_type = Pooled<T, PODPool, false>

Definition at line 27 of file Pool.hpp.

◆ table_type

template<typename T , typename Hash = std::hash<T>, typename KeyEqual = std::equal_to<T>, typename Copy = std::identity, bool ThreadSafe = false>
using m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::table_type = std::unordered_map<T, counter_type, Hash, KeyEqual>

Definition at line 25 of file Pool.hpp.

Constructor & Destructor Documentation

◆ PODPool() [1/2]

template<typename T , typename Hash = std::hash<T>, typename KeyEqual = std::equal_to<T>, typename Copy = std::identity, bool ThreadSafe = false>
m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::PODPool ( )
default

◆ PODPool() [2/2]

template<typename T , typename Hash = std::hash<T>, typename KeyEqual = std::equal_to<T>, typename Copy = std::identity, bool ThreadSafe = false>
m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::PODPool ( std::size_t  initial_capacity)
inline

Definition at line 48 of file Pool.hpp.

◆ ~PODPool()

template<typename T , typename Hash = std::hash<T>, typename KeyEqual = std::equal_to<T>, typename Copy = std::identity, bool ThreadSafe = false>
virtual m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::~PODPool ( )
inlinevirtual

Definition at line 49 of file Pool.hpp.

References M_insist, and m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::table_.

Member Function Documentation

◆ begin()

template<typename T , typename Hash = std::hash<T>, typename KeyEqual = std::equal_to<T>, typename Copy = std::identity, bool ThreadSafe = false>
const_iterator m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::begin ( )
inline

◆ cbegin()

template<typename T , typename Hash = std::hash<T>, typename KeyEqual = std::equal_to<T>, typename Copy = std::identity, bool ThreadSafe = false>
const_iterator m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::cbegin ( ) const
inline

◆ cend()

template<typename T , typename Hash = std::hash<T>, typename KeyEqual = std::equal_to<T>, typename Copy = std::identity, bool ThreadSafe = false>
const_iterator m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::cend ( ) const
inline

◆ end()

template<typename T , typename Hash = std::hash<T>, typename KeyEqual = std::equal_to<T>, typename Copy = std::identity, bool ThreadSafe = false>
const_iterator m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::end ( )
inline

◆ erase()

template<typename T , typename Hash , typename KeyEqual , typename Copy , bool ThreadSafe>
template<bool CanBeNone>
bool m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::erase ( const Pooled< T, PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >, CanBeNone > &  pooled)
private

Erases the pooled entity from the pool.

Requires that the reference count is 0.

Definition at line 357 of file Pool.hpp.

References M_insist, and m::Pooled< T, Pool, CanBeNone >::ref_.

◆ Get()

template<typename T , typename Hash , typename KeyEqual , typename Copy , bool ThreadSafe>
template<bool CanBeNone>
const T & m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::Get ( const Pooled< T, PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >, CanBeNone > &  pooled)
staticprivate

Returns a reference to the value referenced by.

Parameters
pooled.

Definition at line 374 of file Pool.hpp.

References M_insist, m::Pooled< T, Pool, CanBeNone >::ref_, and m::T().

◆ operator()()

template<typename T , typename Hash , typename KeyEqual , typename Copy , bool ThreadSafe>
template<typename U >
PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::proxy_type m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::operator() ( U &&  u)

Returns the pooled.

Parameters
u.

Definition at line 333 of file Pool.hpp.

References m::reader_writer_lock::lock_read(), and M_insist.

◆ size()

template<typename T , typename Hash = std::hash<T>, typename KeyEqual = std::equal_to<T>, typename Copy = std::identity, bool ThreadSafe = false>
std::size_t m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::size ( ) const
inline

Returns the number of elements in the pool.

Definition at line 57 of file Pool.hpp.

References m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::table_.

Friends And Related Function Documentation

◆ Pooled

template<typename T , typename Hash = std::hash<T>, typename KeyEqual = std::equal_to<T>, typename Copy = std::identity, bool ThreadSafe = false>
template<typename , typename , bool >
friend struct Pooled
friend

Definition at line 34 of file Pool.hpp.

Field Documentation

◆ is_thread_safe

template<typename T , typename Hash = std::hash<T>, typename KeyEqual = std::equal_to<T>, typename Copy = std::identity, bool ThreadSafe = false>
constexpr bool m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::is_thread_safe = ThreadSafe
staticconstexpr

Definition at line 36 of file Pool.hpp.

◆ table_

template<typename T , typename Hash = std::hash<T>, typename KeyEqual = std::equal_to<T>, typename Copy = std::identity, bool ThreadSafe = false>
table_type m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::table_
private

◆ table_mutex_

template<typename T , typename Hash = std::hash<T>, typename KeyEqual = std::equal_to<T>, typename Copy = std::identity, bool ThreadSafe = false>
OptField<ThreadSafe, reader_writer_mutex> m::PODPool< T, Hash, KeyEqual, Copy, ThreadSafe >::table_mutex_
mutableprivate

Definition at line 41 of file Pool.hpp.


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