~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/definition/cache.h

  • Committer: Lee Bieber
  • Date: 2011-04-14 16:20:43 UTC
  • mfrom: (2277.1.3 build)
  • Revision ID: kalebral@gmail.com-20110414162043-2khq8mql7gvodnzn
Merge Olaf - Refactor Session Cache and Remove table::Cache::singleton()
Merge Olaf - Refactor Thread
Merge Olaf - remove unused functions

Show diffs side-by-side

added added

removed removed

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