Drizzled Public API Documentation

cache.h
00001 /* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
00002  *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
00003  *
00004  *  Copyright (C) 2010 Brian Aker
00005  *  Copyright (C) 2010 Sun Microsystems, Inc.
00006  *
00007  *  This program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; either version 2 of the License, or
00010  *  (at your option) any later version.
00011  *
00012  *  This program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *  GNU General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with this program; if not, write to the Free Software
00019  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00020  */
00021 
00022 #pragma once
00023 
00024 #include <boost/thread/mutex.hpp>
00025 #include <boost/unordered_map.hpp>
00026 #include <drizzled/identifier.h>
00027 
00028 namespace drizzled {
00029 namespace table {
00030 
00031 typedef boost::unordered_multimap<identifier::Table::Key, Concurrent*> CacheMap;
00032 typedef std::pair<CacheMap::const_iterator, CacheMap::const_iterator> CacheRange;
00033 
00034 class Cache 
00035 {
00036 public:
00037   static CacheMap& getCache()
00038   {
00039     return cache;
00040   }
00041 
00042   static void rehash(size_t arg)
00043   {
00044     cache.rehash(arg);
00045   }
00046 
00047   static boost::mutex& mutex()
00048   {
00049     return _mutex;
00050   }
00051 
00052   static bool areTablesUsed(Table*, bool wait_for_name_lock);
00053   static void removeSchema(const identifier::Schema&);
00054   static bool removeTable(Session&, const identifier::Table&, uint32_t flags);
00055   static void release(table::instance::Shared*);
00056   static void insert(table::Concurrent*);
00057 private:
00058   static CacheMap cache;
00059   static boost::mutex _mutex;
00060 };
00061 
00062 CacheMap& getCache();
00063 void remove_table(table::Concurrent*);
00064 
00065 } /* namepsace table */
00066 } /* namepsace drizzled */
00067