~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/definition/cache.h

  • Committer: Mark Atwood
  • Date: 2011-08-11 03:05:03 UTC
  • mfrom: (2385.1.12 refactor4)
  • Revision ID: me@mark.atwood.name-20110811030503-rp9xjihc5x3y0x4q
mergeĀ lp:~olafvdspek/drizzle/refactor4

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#ifndef DRIZZLED_DEFINITION_CACHE_H
22
 
#define DRIZZLED_DEFINITION_CACHE_H
 
21
#pragma once
23
22
 
24
 
#include "drizzled/table/instance.h"
 
23
#include <drizzled/table/instance.h>
25
24
 
26
25
namespace drizzled {
27
 
 
28
 
namespace generator {
29
 
class TableDefinitionCache;
30
 
}
31
 
 
32
26
namespace definition {
33
27
 
34
28
class Cache
35
29
{
36
30
public:
37
 
  static inline Cache &singleton()
38
 
  {
39
 
    static Cache open_cache;
40
 
 
41
 
    return open_cache;
42
 
  }
43
 
 
44
 
  size_t size() const
45
 
  {
 
31
  static size_t size()
 
32
  {
 
33
    // no lock?
46
34
    return cache.size();
47
35
  }
48
36
 
49
 
  void rehash(size_t arg)
 
37
  static void rehash(size_t arg)
50
38
  {
 
39
    // no lock?
51
40
    cache.rehash(arg);
52
41
  }
53
42
 
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
 
 
 
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);
63
46
private:
 
47
  static void CopyFrom(table::instance::Shared::vector&);
 
48
 
64
49
  typedef boost::unordered_map< identifier::Table::Key, table::instance::Shared::shared_ptr> Map;
65
50
 
66
 
  Map cache;
67
 
  boost::mutex _mutex;
 
51
  static Map cache;
 
52
  static boost::mutex _mutex;
 
53
 
 
54
  friend class generator::TableDefinitionCache;
68
55
};
69
56
 
70
57
} /* namespace definition */
71
58
} /* namespace drizzled */
72
59
 
73
 
#endif /* DRIZZLED_DEFINITION_CACHE_H */