libjmmcg
release_579_6_g8cffd
A C++ library containing an eclectic mix of useful, advanced components.
|
A read-only cache that returns a const reference to the range data. More...
#include <cache.hpp>
Public Types | |
typedef base< Factory > | base_t |
typedef base_t::factory_type | factory_type |
The actual factory type. More... | |
typedef base_t::key_type | key_type |
The type of the key. More... | |
typedef ThrT | thread_traits |
The type of threading in force. More... | |
typedef Stats | statistics_type |
The statistics that will be gathered. More... | |
typedef thread_traits::assoc_colln_t | colln_t |
The type of the internal associative collection. More... | |
typedef colln_t::size_type | size_type |
The size type of the internal associative collection. More... | |
typedef const thread_traits::mapped_type | mapped_type |
The range-data type of the key type. More... | |
typedef thread_traits::flusher_pool_t::exception_type | exception_type |
The base class from which the exceptions that will be thrown by this class are derived. More... | |
typedef thread_traits::flusher_pool_t::pool_traits_type::os_traits | os_traits |
typedef os_traits::lock_traits | lock_traits |
![]() | |
typedef Factory | factory_type |
The factory that is used to create a range-data value for a particular key. More... | |
typedef factory_type::key_type | key_type |
The type of the key. More... | |
typedef factory_type::value_type | value_type |
The type of the range-data. More... | |
Public Member Functions | |
constexpr __stdcall | ro (const size_type low_water, const size_type high_water, const typename thread_traits::populate_pool_t::pool_type::size_type num_threads, const factory_type &f) |
Create an empty read-only cache. More... | |
template<typename Iter > | |
constexpr __stdcall | ro (const size_type low_water, const size_type high_water, const typename thread_traits::populate_pool_t::pool_type::size_type num_threads, const factory_type &f, const Iter &beg, const Iter &end) |
Create a read-only cache and populate it with some values. More... | |
__stdcall | ro (const ro &) |
virtual __stdcall | ~ro (void) noexcept(true) |
ro &__fastcall | operator= (const ro &) |
bool __fastcall | empty (void) const noexcept(true) override |
Indicate if the cache is empty. More... | |
const size_type __fastcall | size (void) const noexcept(true) |
Indicate the number of data items in the cache. More... | |
void __fastcall | clear (void) override |
Synchronously remove all data within the cache. More... | |
template<typename Iter > | |
void __fastcall | insert (const Iter &beg, const Iter &end) |
Synchronously insert a range of values into the cache. More... | |
const mapped_type __fastcall | operator[] (const key_type &key) |
Lookup and return the range-data value associated with a key from the map. More... | |
void __fastcall | flush (void) override |
A synchronous call to flush the cache according to the flush policy. More... | |
const statistics_type &__fastcall | statistics (void) const noexcept(true) |
![]() | |
__stdcall | base (const base &) |
virtual __stdcall | ~base (void) noexcept(true) |
base &__fastcall | operator= (const base &) |
Public Attributes | |
const size_type | low_water_mark |
The "low water mark" of the cache. More... | |
const size_type | high_water_mark |
The "high water mark" of the cache. More... | |
Additional Inherited Members | |
![]() | |
__stdcall | base (const factory_type &f) |
const factory_type &__fastcall | data_factory () const noexcept(true) |
A read-only cache that returns a const reference to the range data.
The cache is a value-type, so you can have caches of caches.
typedef base<Factory> jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::base_t |
typedef thread_traits::assoc_colln_t jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::colln_t |
typedef thread_traits::flusher_pool_t::exception_type jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::exception_type |
typedef base_t::factory_type jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::factory_type |
typedef base_t::key_type jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::key_type |
typedef os_traits::lock_traits jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::lock_traits |
typedef const thread_traits::mapped_type jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::mapped_type |
typedef thread_traits::flusher_pool_t::pool_traits_type::os_traits jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::os_traits |
typedef colln_t::size_type jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::size_type |
typedef Stats jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::statistics_type |
typedef ThrT jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::thread_traits |
|
inlineexplicitconstexpr |
Create an empty read-only cache.
low_water | This is the low_water_mark of the cache. i.e. using the flush policy the cache will attempt to ensure that size()>=low_water_mark. |
high_water | This is the high_water_mark of the cache. i.e. using the flush policy the cache will attempt to ensure that size()<=high_water_mark. |
num_threads | This is the number of threads in the thread pool used for creating range-data for satisfying data requests. This number is set to prevent any data source (e.g. a database) from becoming overwhelmed by requests. |
f | The factory that is used to create a range-data item for a particular key. |
Definition at line 413 of file cache.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::high_water_mark, and jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::low_water_mark.
|
inlineconstexpr |
Create a read-only cache and populate it with some values.
Note that a (possibly) asynchronous flush() may occur after the population to ensure that the max_size of the cache is maintained.
low_water | This is the low_water_mark of the cache. i.e. using the flush policy the cache will attempt to ensure that size()>=low_water_mark. |
high_water | This is the high_water_mark of the cache. i.e. using the flush policy the cache will attempt to ensure that size()<=high_water_mark. |
num_threads | This is the number of threads in the thread pool used for creating range-data for satisfying data requests. This number is set to prevent any data source (e.g. a database) from becoming overwhelmed by requests. |
f | The factory that is used to create a range-data item for a particular key. |
beg | An iterator to the beginning of the source data. |
end | An iterator to the end of the source data. |
Definition at line 430 of file cache.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::high_water_mark, and jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::low_water_mark.
|
inline |
Definition at line 164 of file cache_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::high_water_mark, and jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::low_water_mark.
|
inlinevirtualnoexcept |
Definition at line 171 of file cache_impl.hpp.
|
inlineoverridevirtual |
Synchronously remove all data within the cache.
Note that this does not take into account any outstanding cache fills nor flush()s. Thus after this function it is not guaranteed that empty()==true. This function will reset any statistics upon clearing all contents from the cache.
Implements jmmcg::LIBJMMCG_VER_NAMESPACE::cache::base< Factory >.
Definition at line 200 of file cache_impl.hpp.
|
inlineoverridevirtualnoexcept |
Indicate if the cache is empty.
Note that this does not take into account any outstanding cache fills nor flush()s.
Implements jmmcg::LIBJMMCG_VER_NAMESPACE::cache::base< Factory >.
Definition at line 188 of file cache_impl.hpp.
|
inlineoverridevirtual |
A synchronous call to flush the cache according to the flush policy.
Note that if two or more items within the cache satisfy the victimization criterion, and removing at least one of them would ensure that the max_size criterion is satisfied, it is implementation defined regarding which of those items woulsd be flushed.
Implements jmmcg::LIBJMMCG_VER_NAMESPACE::cache::base< Factory >.
Definition at line 236 of file cache_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::high_water_mark, and jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::low_water_mark.
|
inline |
Synchronously insert a range of values into the cache.
Note that a (possibly) asynchronous flush() may occur after the population to ensure that the size()~<=high_water_mark of the cache is maintained.
beg | An iterator to the beginning of the source data. |
end | An iterator to the end of the source data. |
|
inline |
Definition at line 175 of file cache_impl.hpp.
References jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::high_water_mark, and jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::low_water_mark.
|
inline |
Lookup and return the range-data value associated with a key from the map.
The creation of the range-data value may be asynchronous, as an implementation-defined optimization for multi-threaded caches. A (possibly) asynchronous flush() is called to ensure that the high_water_mark is not exceeded before this function returns. Note that for asynchronous calls to flush(), they are only run once: overlapping calls to flush() will cause the later calls to be quashed, such that no buffering of flush()es occurs. Note that it is guaranteed that empty()==false after this call.
key | The key to look up in the map and return the range-data value. |
Definition at line 207 of file cache_impl.hpp.
|
inlinenoexcept |
Indicate the number of data items in the cache.
Note that this does not take into account any outstanding cache fills nor flush()s.
Definition at line 194 of file cache_impl.hpp.
|
inlinenoexcept |
Definition at line 253 of file cache_impl.hpp.
const size_type jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::high_water_mark |
The "high water mark" of the cache.
The flush policy will attempt to ensure that size()<=high_water_mark. But this is not guaranteed, because there may be outstanding cache fills from another thread.
Definition at line 403 of file cache.hpp.
Referenced by jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::flush(), jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::operator=(), and jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::ro().
const size_type jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::low_water_mark |
The "low water mark" of the cache.
The flush policy will attempt to ensure that size()>=low_water_mark. But this is not guaranteed, because there may be outstanding cache fills from another thread.
Definition at line 396 of file cache.hpp.
Referenced by jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::flush(), jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::operator=(), and jmmcg::LIBJMMCG_VER_NAMESPACE::cache::ro< Factory, FP, ThrT, Stats >::ro().