35 #ifndef MADNESS_WORLD_DIST_CACHE_H__INCLUDED
36 #define MADNESS_WORLD_DIST_CACHE_H__INCLUDED
56 template <
typename keyT>
62 template <
typename>
class CacheData;
69 static cache_container caches_;
84 template <
typename valueT>
86 MADNESS_ASSERT(this->get_type_info() ==
typeid(CacheData<valueT>));
87 return static_cast<const CacheData<valueT>*
>(
this)->value();
95 virtual const std::type_info& get_type_info()
const = 0;
102 template <
typename valueT>
103 class CacheData :
public Cache {
110 CacheData() : value_() { }
116 CacheData(
const valueT& value) : value_(value) { }
119 virtual ~CacheData() { }
131 virtual const std::type_info& get_type_info()
const {
132 return typeid(CacheData<valueT>);
148 template <
typename valueT>
154 if(caches_.
insert(acc, datum_type(key, static_cast<Cache*>(NULL)))) {
157 acc->second =
new CacheData<value_type>(value);
163 Cache* cache = acc->second;
168 cache->template get<value_type>();
169 MADNESS_ASSERT(! f.
probe());
187 template <
typename valueT>
191 if(caches_.
insert(acc, datum_type(key, static_cast<Cache*>(NULL)))) {
193 acc->second =
new CacheData<valueT>(value);
198 Cache* cache = acc->second;
202 value.
set(cache->template get<valueT>());
216 template <
typename valueT>
220 if(caches_.
insert(acc, datum_type(key, static_cast<Cache*>(NULL)))) {
222 acc->second =
new CacheData<valueT>();
230 Cache* cache = acc->second;
243 template <
typename keyT>
244 typename DistCache<keyT>::cache_container DistCache<keyT>::caches_;
249 #endif // MADNESS_WORLD_DIST_CACHE_H__INCLUDED
void release()
Definition: worldhashmap.h:382
Definition: worldhashmap.h:332
bool probe() const
Query the whether this future has been assigned.
Definition: worldfut.h:527
std::pair< const keyT, valueT > datumT
Definition: worldhashmap.h:401
NDIM & f
Definition: mra.h:2179
static void get_cache_value(const keyT &key, madness::Future< valueT > &value)
Get the cache value accosted with key.
Definition: dist_cache.h:188
Definition: worldhashmap.h:57
Distributed caching utility.
Definition: dist_cache.h:57
std::size_t erase(const keyT &key)
Definition: worldhashmap.h:503
static madness::Future< valueT > get_cache_value(const keyT &key)
Get the cache value accosted with key.
Definition: dist_cache.h:217
MUP_BASETYPE value_type
The numeric datatype used by the parser.
Definition: muParserDef.h:222
std::pair< iterator, bool > insert(const datumT &datum)
Definition: worldhashmap.h:469
static void set_cache_value(const keyT &key, const valueT &value)
Set the cache value accosted with key.
Definition: dist_cache.h:149
Implements MadnessException.
void set(const Future< T > &other)
A.set(B) where A & B are futures ensures A has/will have the same value as B.
Definition: worldfut.h:473
Holds machinery to set up Functions/FuncImpls using various Factories and Interfaces.
Definition: chem/atomutil.cc:45
T type
Definition: worldfut.h:130
Defines and implements a concurrent hashmap.