Drizzled Public API Documentation

cache.h
1 /* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3  *
4  * Copyright (C) 2010 Brian Aker
5  * Copyright (C) 2010 Sun Microsystems, Inc.
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #pragma once
23 
24 #include <boost/thread/mutex.hpp>
25 #include <boost/unordered_map.hpp>
26 #include <drizzled/identifier.h>
27 
28 namespace drizzled {
29 namespace table {
30 
31 typedef boost::unordered_multimap<identifier::Table::Key, Concurrent*> CacheMap;
32 typedef std::pair<CacheMap::const_iterator, CacheMap::const_iterator> CacheRange;
33 
34 class Cache
35 {
36 public:
37  static CacheMap& getCache()
38  {
39  return cache;
40  }
41 
42  static void rehash(size_t arg)
43  {
44  cache.rehash(arg);
45  }
46 
47  static boost::mutex& mutex()
48  {
49  return _mutex;
50  }
51 
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 private:
58  static CacheMap cache;
59  static boost::mutex _mutex;
60 };
61 
62 CacheMap& getCache();
63 void remove_table(table::Concurrent*);
64 
65 } /* namepsace table */
66 } /* namepsace drizzled */
67