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
-
keyT | The key type of the cache |
template<typename keyT >
template<typename valueT >
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
-
valueT | The object type that will be used to set the cache |
- Parameters
-
[in] | key | The 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().
template<typename keyT >
template<typename valueT >
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
-
valueT | The object type that will be used to set the cache |
- Parameters
-
[in] | key | The key associated with value |
[out] | value | The 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().
template<typename keyT >
template<typename valueT >
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
-
valueT | The object type that will be used to set the cache (may be a madness::Future type). |
- Parameters
-
key | The key associated with value |
value | The 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().