23
23
#include <boost/bind.hpp>
25
#include <drizzled/identifier.h>
25
26
#include <drizzled/error.h>
26
27
#include <drizzled/catalog.h>
27
28
#include <drizzled/plugin/catalog.h>
30
31
#include <boost/thread/mutex.hpp>
32
33
namespace drizzled {
43
} //namespace generator
55
static inline Cache &singleton()
57
static Cache open_cache;
64
41
return cache.size();
67
void rehash(size_t arg)
72
Instance::shared_ptr find(const identifier::Catalog &identifier, drizzled::error_t &error);
73
bool exist(const identifier::Catalog &identifier);
74
bool erase(const identifier::Catalog &identifier, drizzled::error_t &error);
75
bool insert(const identifier::Catalog &identifier, Instance::shared_ptr instance, drizzled::error_t &error);
76
bool lock(const identifier::Catalog &identifier, drizzled::error_t &error);
77
bool unlock(const identifier::Catalog &identifier, drizzled::error_t &error);
79
friend class drizzled::generator::catalog::Cache;
80
friend class drizzled::plugin::Catalog;
81
friend class drizzled::catalog::lock::Erase;
82
friend class drizzled::catalog::lock::Create;
84
void copy(catalog::Instance::vector &vector);
86
typedef boost::unordered_map< identifier::Catalog, catalog::Instance::shared_ptr> unordered_map;
44
static Instance::shared_ptr find(const identifier::Catalog&, error_t&);
45
static bool exist(const identifier::Catalog&);
46
static bool erase(const identifier::Catalog&, error_t&);
47
static bool insert(const identifier::Catalog&, Instance::shared_ptr, error_t&);
48
static bool lock(const identifier::Catalog&, error_t&);
49
static bool unlock(const identifier::Catalog&, error_t&);
50
static void copy(catalog::Instance::vector&);
52
typedef boost::unordered_map<identifier::Catalog, catalog::Instance::shared_ptr> unordered_map;
54
static unordered_map cache;
55
static boost::mutex _mutex;
118
if (not catalog::Cache::singleton().unlock(identifier, error))
84
if (not catalog::Cache::unlock(identifier, error))
120
86
my_error(error, identifier);
129
95
// We insert a lock into the cache, if this fails we bail.
130
if (not catalog::Cache::singleton().lock(identifier, error))
96
if (not catalog::Cache::lock(identifier, error))
164
if (not catalog::Cache::singleton().unlock(identifier, error))
130
if (not catalog::Cache::unlock(identifier, error))
166
132
my_error(error, identifier);
176
142
// We insert a lock into the cache, if this fails we bail.
177
if (not catalog::Cache::singleton().lock(identifier, error))
143
if (not catalog::Cache::lock(identifier, error))
179
145
my_error(error, identifier);