Chris@16: // Copyright 2004 The Trustees of Indiana University. Chris@16: Chris@16: // Use, modification and distribution is subject to the Boost Software Chris@16: // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: // Authors: Douglas Gregor Chris@16: // Andrew Lumsdaine Chris@16: #ifndef BOOST_PARALLEL_CACHING_PROPERTY_MAP_HPP Chris@16: #define BOOST_PARALLEL_CACHING_PROPERTY_MAP_HPP Chris@16: Chris@16: #include Chris@16: Chris@16: namespace boost { Chris@16: Chris@16: // This probably doesn't belong here Chris@16: template Chris@16: inline void local_put(dummy_property_map, const Key&, const Value&) {} Chris@16: Chris@16: namespace parallel { Chris@16: Chris@16: /** Property map that caches values placed in it but does not Chris@16: * broadcast values to remote processors. This class template is Chris@16: * meant as an adaptor for @ref distributed_property_map that Chris@16: * suppresses communication in the event of a remote @c put operation Chris@16: * by mapping it to a local @c put operation. Chris@16: * Chris@16: * @todo Find a better name for @ref caching_property_map Chris@16: */ Chris@16: template Chris@16: class caching_property_map Chris@16: { Chris@16: public: Chris@16: typedef typename property_traits::key_type key_type; Chris@16: typedef typename property_traits::value_type value_type; Chris@16: typedef typename property_traits::reference reference; Chris@16: typedef typename property_traits::category category; Chris@16: Chris@16: explicit caching_property_map(const PropertyMap& property_map) Chris@16: : property_map(property_map) {} Chris@16: Chris@16: PropertyMap& base() { return property_map; } Chris@16: const PropertyMap& base() const { return property_map; } Chris@16: Chris@16: template Chris@16: void set_reduce(const Reduce& reduce) Chris@16: { property_map.set_reduce(reduce); } Chris@16: Chris@16: void reset() { property_map.reset(); } Chris@16: Chris@16: #if 0 Chris@16: reference operator[](const key_type& key) const Chris@16: { Chris@16: return property_map[key]; Chris@16: } Chris@16: #endif Chris@16: Chris@16: private: Chris@16: PropertyMap property_map; Chris@16: }; Chris@16: Chris@16: template Chris@16: inline typename caching_property_map::value_type Chris@16: get(const caching_property_map& pm, const Key& key) Chris@16: { return get(pm.base(), key); } Chris@16: Chris@16: template Chris@16: inline void Chris@16: local_put(const caching_property_map& pm, const Key& key, Chris@16: const Value& value) Chris@16: { local_put(pm.base(), key, value); } Chris@16: Chris@16: template Chris@16: inline void Chris@16: cache(const caching_property_map& pm, const Key& key, Chris@16: const Value& value) Chris@16: { cache(pm.base(), key, value); } Chris@16: Chris@16: template Chris@16: inline void Chris@16: put(const caching_property_map& pm, const Key& key, Chris@16: const Value& value) Chris@16: { local_put(pm.base(), key, value); } Chris@16: Chris@16: template Chris@16: inline caching_property_map Chris@16: make_caching_property_map(const PropertyMap& pm) Chris@16: { return caching_property_map(pm); } Chris@16: Chris@16: } } // end namespace boost::parallel Chris@16: Chris@16: #endif // BOOST_PARALLEL_CACHING_PROPERTY_MAP_HPP