~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/definition/cache.h

  • Committer: Brian Aker
  • Date: 2010-11-04 20:51:35 UTC
  • mto: This revision was merged to the branch mainline in revision 1906.
  • Revision ID: brian@tangent.org-20101104205135-vci0i54v1d0loai8
Merge of partial set of patches for locks.

Show diffs side-by-side

added added

removed removed

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