MADNESS 0.10.1
Classes | Static Public Member Functions | Private Types | Static Private Attributes | List of all members
madness::detail::DistCache< keyT > Class Template Reference

Distributed caching utility. More...

#include <dist_cache.h>

Collaboration diagram for madness::detail::DistCache< keyT >:
Collaboration graph
[legend]

Classes

class  Cache
 Cache interface class. More...
 
class  CacheData
 Cache value container. More...
 

Static Public Member Functions

template<typename valueT >
static madness::Future< valueTget_cache_value (const keyT &key)
 Get the cache value accosted with key.
 
template<typename valueT >
static void get_cache_value (const keyT &key, madness::Future< valueT > &value)
 Get the cache value accosted with key.
 
template<typename valueT >
static void set_cache_value (const keyT &key, const valueT &value)
 Set the cache value accosted with key.
 

Private Types

typedef madness::ConcurrentHashMap< keyT, Cache * > cache_container
 The container that holds cache values.
 
typedef cache_container::datumT datum_type
 Cache container datum type.
 

Static Private Attributes

static cache_container caches_
 Cache container.
 

Detailed Description

template<typename keyT>
class madness::detail::DistCache< keyT >

Distributed caching utility.

This object implements a local, key-value caching mechanism that can be used by remote tasks or active messages to move data between processes without synchronization. Because cache values are retrieved via a Future, you can get or set the cache in any order. The first call get_cache_value or set_cache_value or will insert the cache element, and the second call to these functions will remove it. Therefore, set_cache_value and get_cache_value can only be called once each per cache value.

Template Parameters
keyTThe key type of the cache

Member Typedef Documentation

◆ cache_container

template<typename keyT >
typedef madness::ConcurrentHashMap<keyT, Cache*> madness::detail::DistCache< keyT >::cache_container
private

The container that holds cache values.

◆ datum_type

template<typename keyT >
typedef cache_container::datumT madness::detail::DistCache< keyT >::datum_type
private

Cache container datum type.

Member Function Documentation

◆ get_cache_value() [1/2]

template<typename keyT >
template<typename valueT >
static madness::Future< valueT > madness::detail::DistCache< keyT >::get_cache_value ( const keyT &  key)
inlinestatic

Get the cache value accosted with key.

This will get the value associated with key to value. If the cache element does not exist, it is inserted into the cache. Otherwise, it is removed from the cache.

Template Parameters
valueTThe object type that will be used to set the cache
Parameters
[in]keyThe key associated with value
Returns
A Future that holds/will hold the cache value, which will be set by a call to set_cache_value.

References madness::cache, madness::detail::DistCache< keyT >::caches_, madness::ConcurrentHashMap< keyT, valueT, hashfunT >::erase(), madness::ConcurrentHashMap< keyT, valueT, hashfunT >::insert(), and madness::Hash_private::HashAccessor< hashT, lockmode >::release().

◆ get_cache_value() [2/2]

template<typename keyT >
template<typename valueT >
static void madness::detail::DistCache< keyT >::get_cache_value ( const keyT &  key,
madness::Future< valueT > &  value 
)
inlinestatic

Get the cache value accosted with key.

This will get the value associated with key to value. The value is given in the form of a Future, which is set by a call to set_cache_value. If the cache element does not exist, it is inserted into the cache. Otherwise, it is removed from the cache.

Template Parameters
valueTThe object type that will be used to set the cache
Parameters
[in]keyThe key associated with value
[out]valueThe data that will be cached

References madness::cache, madness::detail::DistCache< keyT >::caches_, madness::ConcurrentHashMap< keyT, valueT, hashfunT >::erase(), madness::ConcurrentHashMap< keyT, valueT, hashfunT >::insert(), madness::Hash_private::HashAccessor< hashT, lockmode >::release(), and madness::Future< T >::set().

Referenced by madness::WorldGopInterface::bcast_internal(), and madness::WorldGopInterface::bcast_internal().

◆ set_cache_value()

template<typename keyT >
template<typename valueT >
static void madness::detail::DistCache< keyT >::set_cache_value ( const keyT &  key,
const valueT value 
)
inlinestatic

Set the cache value accosted with key.

This will set the value associated with key to value. If the cache element does not exist, it is inserted into the cache. Otherwise, it is removed from the cache.

Template Parameters
valueTThe object type that will be used to set the cache (may be a madness::Future type).
Parameters
keyThe key associated with value
valueThe data that will be cached

References madness::cache, madness::detail::DistCache< keyT >::caches_, madness::ConcurrentHashMap< keyT, valueT, hashfunT >::erase(), madness::f, madness::ConcurrentHashMap< keyT, valueT, hashfunT >::insert(), MADNESS_ASSERT, and madness::Hash_private::HashAccessor< hashT, lockmode >::release().

Referenced by madness::WorldGopInterface::bcast_task(), and madness::WorldGopInterface::group_bcast_task().

Member Data Documentation

◆ caches_

template<typename keyT >
DistCache< keyT >::cache_container madness::detail::DistCache< keyT >::caches_
staticprivate

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