drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
table/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 <unordered_map>
26#include <drizzled/identifier.h>
27
28namespace drizzled {
29namespace table {
30
31typedef std::unordered_multimap<identifier::Table::Key, Concurrent*> CacheMap;
32typedef std::pair<CacheMap::const_iterator, CacheMap::const_iterator> CacheRange;
33
34class Cache
35{
36public:
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*);
57private:
58 static CacheMap cache;
59 static boost::mutex _mutex;
60};
61
62CacheMap& getCache();
63void remove_table(table::Concurrent*);
64
65} /* namepsace table */
66} /* namepsace drizzled */
67
TODO: Rename this file - func.h is stupid.