~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to drizzled/definition/cache.h

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include <drizzled/table/instance.h>
24
24
 
25
25
namespace drizzled {
26
 
 
27
 
namespace generator {
28
 
class TableDefinitionCache;
29
 
}
30
 
 
31
26
namespace definition {
32
27
 
33
28
class Cache
34
29
{
35
30
public:
36
 
  static inline Cache &singleton()
37
 
  {
38
 
    static Cache open_cache;
39
 
 
40
 
    return open_cache;
41
 
  }
42
 
 
43
 
  size_t size() const
44
 
  {
 
31
  static size_t size()
 
32
  {
 
33
    // no lock?
45
34
    return cache.size();
46
35
  }
47
36
 
48
 
  void rehash(size_t arg)
 
37
  static void rehash(size_t arg)
49
38
  {
 
39
    // no lock?
50
40
    cache.rehash(arg);
51
41
  }
52
42
 
53
 
  table::instance::Shared::shared_ptr find(const identifier::Table::Key &identifier);
54
 
  void erase(const identifier::Table::Key &identifier);
55
 
  bool insert(const identifier::Table::Key &identifier, table::instance::Shared::shared_ptr share);
56
 
 
57
 
protected:
58
 
  friend class drizzled::generator::TableDefinitionCache;
59
 
 
60
 
  void CopyFrom(table::instance::Shared::vector &vector);
61
 
 
 
43
  static table::instance::Shared::shared_ptr find(const identifier::Table::Key&);
 
44
  static void erase(const identifier::Table::Key&);
 
45
  static bool insert(const identifier::Table::Key&, table::instance::Shared::shared_ptr);
62
46
private:
 
47
  static void CopyFrom(table::instance::Shared::vector&);
 
48
 
63
49
  typedef boost::unordered_map< identifier::Table::Key, table::instance::Shared::shared_ptr> Map;
64
50
 
65
 
  Map cache;
66
 
  boost::mutex _mutex;
 
51
  static Map cache;
 
52
  static boost::mutex _mutex;
 
53
 
 
54
  friend class generator::TableDefinitionCache;
67
55
};
68
56
 
69
57
} /* namespace definition */