3#include "GlobalParam.h"
98 using container_t = std::unordered_map<concurrent_key_t, T>;
111 container_t m_container;
129 template <
typename T>
130 static std::unique_ptr<ConcurrentParam<T>>
Create() {
136 return std::make_unique<SingleThreadParam<T>>();
138 return std::make_unique<MemoizedParam<T>>();
140 throw std::runtime_error(
"unknown GlobalConcurrencyModel '" +
GlobalConcurrencyModel() +
"'; valid options are 'single' or 'memoize'");
factory to create the appropriate ConcurrentParam-derived class instance for the current GlobalConcur...
static std::unique_ptr< ConcurrentParam< T > > Create()
create a new ConcurrentParam-derived class instance
abstract base class for concurrently mutable configuration parameters
virtual void Save(T const &value, concurrent_key_t const key)=0
modify a value
std::mutex m_mutex
mutex for this ConcurrentParam
bool m_needs_hashing
whether this ConcurrentParam needs hashing for calling Load or Save
virtual bool HasKey(concurrent_key_t const key) const =0
bool NeedsHashing() const
whether or not hashing is needed to use this parameter
virtual std::size_t GetSize() const =0
bool m_empty
whether this ConcurrentParam has something saved
virtual T const Load(concurrent_key_t const key) const =0
access a stored value
ConcurrentParam(std::string const &model)
an iguana::ConcurrentParam that uses memoization for thread safety; used when iguana::GlobalConcurren...
T const Load(concurrent_key_t const key) const override
access a stored value
bool HasKey(concurrent_key_t const key) const override
std::size_t GetSize() const override
void Save(T const &value, concurrent_key_t const key) override
modify a value
a parameter that is not thread safe; used when iguana::GlobalConcurrencyModel is "single"
std::size_t GetSize() const override
void Save(T const &value, concurrent_key_t const key) override
modify a value
T const Load(concurrent_key_t const key) const override
access a stored value
bool HasKey(concurrent_key_t const key) const override
General, top-level namespace for algorithms and infrastructure. For algorithms and bindings,...
std::size_t concurrent_key_t
concurrent hash key type
GlobalParam< std::string > GlobalConcurrencyModel
The concurrency model, for running certain algorithms in a thread-safe way.