00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #pragma once
00021
00022 #include <list>
00023
00024 #include <drizzled/visibility.h>
00025
00026 namespace drizzled
00027 {
00028
00029 class Session;
00030
00031 namespace session
00032 {
00033
00034 class DRIZZLED_API Cache
00035 {
00036 typedef boost::shared_ptr<drizzled::Session> session_shared_ptr;
00037 public:
00038 typedef std::list<session_shared_ptr> list;
00039
00040 Cache() :
00041 _ready_to_exit(false)
00042 {
00043 }
00044
00045 static inline Cache &singleton()
00046 {
00047 static Cache open_cache;
00048
00049 return open_cache;
00050 }
00051
00052 list &getCache()
00053 {
00054 return cache;
00055 }
00056
00057 boost::mutex &mutex()
00058 {
00059 return _mutex;
00060 }
00061
00062 boost::condition_variable &cond()
00063 {
00064 return _end;
00065 }
00066
00067 void shutdownFirst();
00068 void shutdownSecond();
00069
00070 void erase(session_shared_ptr&);
00071 size_t count();
00072 void insert(session_shared_ptr &arg);
00073
00074 session_shared_ptr find(const session_id_t &id);
00075
00076 private:
00077 bool volatile _ready_to_exit;
00078 list cache;
00079 boost::mutex _mutex;
00080 boost::condition_variable _end;
00081 };
00082
00083 }
00084 }
00085