~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table/cache.h

  • Committer: Monty Taylor
  • Date: 2010-09-28 07:45:44 UTC
  • mto: (1799.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 1800.
  • Revision ID: mordred@inaugust.com-20100928074544-s3ujnv6s8wro74l2
Added BSD copying file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
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
 
#ifndef DRIZZLED_TABLE_CACHE_H
23
 
#define DRIZZLED_TABLE_CACHE_H
24
 
 
25
 
#include <boost/unordered_map.hpp>
26
 
 
27
 
namespace drizzled {
28
 
namespace table {
29
 
 
30
 
class Concurrent;
31
 
 
32
 
typedef boost::unordered_multimap< TableIdentifier::Key, Concurrent *> CacheMap;
33
 
typedef std::pair< CacheMap::const_iterator, CacheMap::const_iterator > CacheRange;
34
 
 
35
 
class Cache 
36
 
{
37
 
  CacheMap cache;
38
 
 
39
 
public:
40
 
  static inline Cache &singleton()
41
 
  {
42
 
    static Cache open_cache;
43
 
 
44
 
    return open_cache;
45
 
  }
46
 
 
47
 
  CacheMap &getCache()
48
 
  {
49
 
    return cache;
50
 
  }
51
 
 
52
 
  void rehash(size_t arg)
53
 
  {
54
 
    cache.rehash(arg);
55
 
  }
56
 
 
57
 
  bool areTablesUsed(Table *table, bool wait_for_name_lock);
58
 
  void removeSchema(const SchemaIdentifier &schema_identifier);
59
 
  bool removeTable(Session *session, TableIdentifier &identifier, uint32_t flags);
60
 
  void release(TableShare *share);
61
 
  bool insert(table::Concurrent *arg);
62
 
 
63
 
  boost::mutex &mutex()
64
 
  {
65
 
    return _mutex;
66
 
  }
67
 
 
68
 
private:
69
 
  boost::mutex _mutex;
70
 
};
71
 
 
72
 
CacheMap &getCache(void);
73
 
void remove_table(table::Concurrent *arg);
74
 
 
75
 
} /* namepsace table */
76
 
} /* namepsace drizzled */
77
 
 
78
 
#endif /* DRIZZLED_TABLE_CACHE_H */