00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #pragma once
00023
00024 #include <boost/unordered_map.hpp>
00025 #include <drizzled/identifier.h>
00026
00027 namespace drizzled {
00028
00029 class Session;
00030
00031 namespace table {
00032
00033 namespace instance {
00034 class Shared;
00035 }
00036
00037 class Concurrent;
00038
00039 typedef boost::unordered_multimap< identifier::Table::Key, Concurrent *> CacheMap;
00040 typedef std::pair< CacheMap::const_iterator, CacheMap::const_iterator > CacheRange;
00041
00042 class Cache
00043 {
00044 CacheMap cache;
00045
00046 public:
00047 static inline Cache &singleton()
00048 {
00049 static Cache open_cache;
00050
00051 return open_cache;
00052 }
00053
00054 CacheMap &getCache()
00055 {
00056 return cache;
00057 }
00058
00059 void rehash(size_t arg)
00060 {
00061 cache.rehash(arg);
00062 }
00063
00064 bool areTablesUsed(Table *table, bool wait_for_name_lock);
00065 void removeSchema(const identifier::Schema &schema_identifier);
00066 bool removeTable(Session *session, identifier::Table &identifier, uint32_t flags);
00067 void release(table::instance::Shared *share);
00068 bool insert(table::Concurrent *arg);
00069
00070 boost::mutex &mutex()
00071 {
00072 return _mutex;
00073 }
00074
00075 private:
00076 boost::mutex _mutex;
00077 };
00078
00079 CacheMap &getCache(void);
00080 void remove_table(table::Concurrent *arg);
00081
00082 }
00083 }
00084