~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table/cache.h

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20
20
 */
21
21
 
22
 
#pragma once
 
22
#ifndef DRIZZLED_TABLE_CACHE_H
 
23
#define DRIZZLED_TABLE_CACHE_H
23
24
 
24
 
#include <boost/thread/mutex.hpp>
25
25
#include <boost/unordered_map.hpp>
26
26
#include <drizzled/identifier.h>
27
27
 
28
28
namespace drizzled {
 
29
 
 
30
class Session;
 
31
 
29
32
namespace table {
30
33
 
31
 
typedef boost::unordered_multimap<identifier::Table::Key, Concurrent*> CacheMap;
32
 
typedef std::pair<CacheMap::const_iterator, CacheMap::const_iterator> CacheRange;
 
34
namespace instance {
 
35
class Shared;
 
36
 
37
 
 
38
class Concurrent;
 
39
 
 
40
typedef boost::unordered_multimap< identifier::Table::Key, Concurrent *> CacheMap;
 
41
typedef std::pair< CacheMap::const_iterator, CacheMap::const_iterator > CacheRange;
33
42
 
34
43
class Cache 
35
44
{
 
45
  CacheMap cache;
 
46
 
36
47
public:
37
 
  static CacheMap& getCache()
 
48
  static inline Cache &singleton()
 
49
  {
 
50
    static Cache open_cache;
 
51
 
 
52
    return open_cache;
 
53
  }
 
54
 
 
55
  CacheMap &getCache()
38
56
  {
39
57
    return cache;
40
58
  }
41
59
 
42
 
  static void rehash(size_t arg)
 
60
  void rehash(size_t arg)
43
61
  {
44
62
    cache.rehash(arg);
45
63
  }
46
64
 
47
 
  static boost::mutex& mutex()
 
65
  bool areTablesUsed(Table *table, bool wait_for_name_lock);
 
66
  void removeSchema(const identifier::Schema &schema_identifier);
 
67
  bool removeTable(Session *session, identifier::Table &identifier, uint32_t flags);
 
68
  void release(table::instance::Shared *share);
 
69
  bool insert(table::Concurrent *arg);
 
70
 
 
71
  boost::mutex &mutex()
48
72
  {
49
73
    return _mutex;
50
74
  }
51
75
 
52
 
  static bool areTablesUsed(Table*, bool wait_for_name_lock);
53
 
  static void removeSchema(const identifier::Schema&);
54
 
  static bool removeTable(Session&, const identifier::Table&, uint32_t flags);
55
 
  static void release(table::instance::Shared*);
56
 
  static void insert(table::Concurrent*);
57
76
private:
58
 
  static CacheMap cache;
59
 
  static boost::mutex _mutex;
 
77
  boost::mutex _mutex;
60
78
};
61
79
 
62
 
CacheMap& getCache();
63
 
void remove_table(table::Concurrent*);
 
80
CacheMap &getCache(void);
 
81
void remove_table(table::Concurrent *arg);
64
82
 
65
83
} /* namepsace table */
66
84
} /* namepsace drizzled */
67
85
 
 
86
#endif /* DRIZZLED_TABLE_CACHE_H */