![]() |
mutable
A Database System for Research and Fast Prototyping
|
A pool implements an implicitly garbage-collected set of instances of a class hierarchy. More...
#include <Pool.hpp>
Data Structures | |
struct | dereference_equal_to |
struct | dereference_hash |
Public Types | |
using | counter_type = std::conditional_t< ThreadSafe, std::atomic< uint32_t >, uint32_t > |
using | table_type = std::unordered_map< std::unique_ptr< T >, counter_type, dereference_hash, dereference_equal_to > |
using | pooled_type = T |
template<typename U > | |
using | proxy_type = Pooled< U, Pool, false > |
template<typename U > | |
using | proxy_optional_type = Pooled< U, Pool, true > |
using | hasher = Hash |
using | key_equal = KeyEqual |
using | const_iterator = table_type::const_iterator |
Public Member Functions | |
Pool ()=default | |
Pool (std::size_t initial_capacity) | |
~Pool () | |
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 > requires std::derived_from<U, T> | |
Pooled< U, Pool, false > | operator() (U &&u) |
Returns the pooled. | |
template<typename U > requires std::derived_from<U, T> | |
Pool< T, Hash, KeyEqual, ThreadSafe >::proxy_type< U > | operator() (U &&u) |
Static Public Attributes | |
static constexpr bool | is_thread_safe = ThreadSafe |
Private Member Functions | |
template<typename U , bool CanBeNone> | |
bool | erase (const Pooled< U, Pool, CanBeNone > &pooled) |
Erases the pooled entity from the pool. | |
Static Private Member Functions | |
template<typename U , bool CanBeNone> requires std::derived_from<U, T> | |
static const U & | Get (const Pooled< U, Pool, CanBeNone > &pooled) |
Returns a reference to the value referenced by. | |
Private Attributes | |
table_type | table_ |
OptField< ThreadSafe, reader_writer_mutex > | table_mutex_ |
Friends | |
template<typename , typename , bool > | |
struct | Pooled |
A pool implements an implicitly garbage-collected set of instances of a class hierarchy.
using m::Pool< T, Hash, KeyEqual, ThreadSafe >::table_type = std::unordered_map<std::unique_ptr<T>, counter_type, dereference_hash, dereference_equal_to> |
|
default |
|
inline |
Definition at line 126 of file Pool.hpp.
References M_insist, and m::Pool< T, Hash, KeyEqual, ThreadSafe >::table_.
|
inline |
Definition at line 139 of file Pool.hpp.
References m::Pool< T, Hash, KeyEqual, ThreadSafe >::table_.
|
inline |
Definition at line 141 of file Pool.hpp.
References m::Pool< T, Hash, KeyEqual, ThreadSafe >::table_.
|
inline |
Definition at line 142 of file Pool.hpp.
References m::Pool< T, Hash, KeyEqual, ThreadSafe >::table_.
|
inline |
Definition at line 140 of file Pool.hpp.
References m::Pool< T, Hash, KeyEqual, ThreadSafe >::table_.
|
private |
Erases the pooled entity from the pool.
Requires that the reference count is 0
.
Definition at line 407 of file Pool.hpp.
References M_insist, and m::Pooled< T, Pool, CanBeNone >::ref_.
|
staticprivate |
Returns a reference to the value referenced by.
pooled. |
Definition at line 425 of file Pool.hpp.
References M_insist, m::Pooled< T, Pool, CanBeNone >::ref_, and m::U.
Referenced by m::Pooled< T, Pool, CanBeNone >::dump(), m::Pooled< T, Pool, CanBeNone >::operator const T &(), m::Pooled< T, Pool, CanBeNone >::operator const T *(), m::Pooled< T, Pool, CanBeNone >::operator*(), m::Pooled< T, Pool, CanBeNone >::operator->(), and m::Pooled< T, Pool, CanBeNone >::operator==().
Pooled< U, Pool, false > m::Pool< T, Hash, KeyEqual, ThreadSafe >::operator() | ( | U && | u | ) |
Returns the pooled.
u. |
Pool< T, Hash, KeyEqual, ThreadSafe >::proxy_type< U > m::Pool< T, Hash, KeyEqual, ThreadSafe >::operator() | ( | U && | u | ) |
Definition at line 383 of file Pool.hpp.
References m::reader_writer_lock::lock_read(), M_insist, and m::U.
|
inline |
Returns the number of elements in the pool.
Definition at line 137 of file Pool.hpp.
References m::Pool< T, Hash, KeyEqual, ThreadSafe >::table_.
|
private |
Definition at line 116 of file Pool.hpp.
Referenced by m::Pool< T, Hash, KeyEqual, ThreadSafe >::begin(), m::Pool< T, Hash, KeyEqual, ThreadSafe >::cbegin(), m::Pool< T, Hash, KeyEqual, ThreadSafe >::cend(), m::Pool< T, Hash, KeyEqual, ThreadSafe >::end(), m::Pool< T, Hash, KeyEqual, ThreadSafe >::size(), and m::Pool< T, Hash, KeyEqual, ThreadSafe >::~Pool().
|
mutableprivate |