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) 2009 Sun Microsystems, Inc.
00005  *
00006  *  This program is free software; you can redistribute it and/or modify
00007  *  it under the terms of the GNU General Public License as published by
00008  *  the Free Software Foundation; version 2 of the License.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00018  */
00019 
00020 #pragma once
00021 
00022 #include <boost/thread/condition_variable.hpp>
00023 #include <boost/thread/mutex.hpp>
00024 #include <drizzled/visibility.h>
00025 #include <drizzled/common_fwd.h>
00026 #include <list>
00027 
00028 namespace drizzled {
00029 namespace session {
00030 
00031 class DRIZZLED_API Cache 
00032 {
00033   typedef boost::shared_ptr<drizzled::Session> session_ptr;
00034 public:
00035   typedef std::list<session_ptr> list;
00036 
00037   static list &getCache()
00038   {
00039     return cache;
00040   }
00041 
00042   static boost::mutex &mutex()
00043   {
00044     return _mutex;
00045   }
00046 
00047   static boost::condition_variable &cond()
00048   {
00049     return _end;
00050   }
00051 
00052   static void shutdownFirst();
00053   static void shutdownSecond();
00054 
00055   static void erase(const session_ptr&);
00056   static size_t count();
00057   static void insert(const session_ptr&);
00058 
00059   static session_ptr find(const session_id_t&);
00060 
00061 private:
00062   static bool volatile _ready_to_exit;
00063   static list cache;
00064   static boost::mutex _mutex;
00065   static boost::condition_variable _end;
00066 };
00067 
00068 } /* namespace session */
00069 } /* namespace drizzled */
00070