expose a clear method for the marker_cache and mapped_memory_cache - closes #1022

This commit is contained in:
Dane Springmeyer 2012-03-09 15:16:01 -08:00
parent 71333373cc
commit ddd3956f0e
4 changed files with 22 additions and 3 deletions

View file

@ -49,6 +49,7 @@ struct MAPNIK_DECL mapped_memory_cache :
static boost::unordered_map<std::string,mapped_region_ptr> cache_;
static bool insert(std::string const& key, mapped_region_ptr);
static boost::optional<mapped_region_ptr> find(std::string const& key, bool update_cache = false);
static void clear();
};
}

View file

@ -50,6 +50,7 @@ struct MAPNIK_DECL marker_cache :
static boost::unordered_map<std::string,marker_ptr> cache_;
static bool insert(std::string const& key, marker_ptr);
static boost::optional<marker_ptr> find(std::string const& key, bool update_cache = false);
static void clear();
};
}

View file

@ -29,13 +29,22 @@
#include <boost/assert.hpp>
#include <boost/interprocess/file_mapping.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/make_shared.hpp>
namespace mapnik
{
boost::unordered_map<std::string, mapped_region_ptr> mapped_memory_cache::cache_;
bool mapped_memory_cache::insert (std::string const& uri, mapped_region_ptr mem)
void mapped_memory_cache::clear()
{
#ifdef MAPNIK_THREADSAFE
mutex::scoped_lock lock(mutex_);
#endif
return cache_.clear();
}
bool mapped_memory_cache::insert(std::string const& uri, mapped_region_ptr mem)
{
#ifdef MAPNIK_THREADSAFE
mutex::scoped_lock lock(mutex_);
@ -63,7 +72,7 @@ boost::optional<mapped_region_ptr> mapped_memory_cache::find(std::string const&
try
{
file_mapping mapping(uri.c_str(),read_only);
mapped_region_ptr region(new mapped_region(mapping,read_only));
mapped_region_ptr region(boost::make_shared<mapped_region>(mapping,read_only));
result.reset(region);

View file

@ -44,7 +44,15 @@ namespace mapnik
boost::unordered_map<std::string, marker_ptr> marker_cache::cache_;
bool marker_cache::insert (std::string const& uri, marker_ptr path)
void marker_cache::clear()
{
#ifdef MAPNIK_THREADSAFE
mutex::scoped_lock lock(mutex_);
#endif
return cache_.clear();
}
bool marker_cache::insert(std::string const& uri, marker_ptr path)
{
#ifdef MAPNIK_THREADSAFE
mutex::scoped_lock lock(mutex_);