~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session/cache.h

Merge Monty - Updates to pandora-build to support features of gcc 4.5.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#pragma once
 
20
#ifndef DRIZZLED_SESSION_CACHE_H
 
21
#define DRIZZLED_SESSION_CACHE_H
21
22
 
22
 
#include <boost/thread/condition_variable.hpp>
23
 
#include <boost/thread/mutex.hpp>
24
 
#include <drizzled/visibility.h>
 
23
#include "drizzled/session.h"
25
24
#include <list>
26
25
 
27
 
namespace drizzled {
28
 
namespace session {
29
 
 
30
 
class DRIZZLED_API Cache 
31
 
{
32
 
  typedef boost::shared_ptr<drizzled::Session> session_ptr;
 
26
namespace drizzled
 
27
{
 
28
 
 
29
class Session;
 
30
 
 
31
namespace session
 
32
{
 
33
 
 
34
class Cache 
 
35
{
33
36
public:
34
 
  typedef std::list<session_ptr> list;
35
 
 
36
 
  static list &getCache()
 
37
  typedef std::list<Session::shared_ptr> list;
 
38
 
 
39
  static inline Cache &singleton()
 
40
  {
 
41
    static Cache open_cache;
 
42
 
 
43
    return open_cache;
 
44
  }
 
45
 
 
46
  list &getCache()
37
47
  {
38
48
    return cache;
39
49
  }
40
50
 
41
 
  static boost::mutex &mutex()
 
51
  boost::mutex &mutex()
42
52
  {
43
53
    return _mutex;
44
54
  }
45
55
 
46
 
  static boost::condition_variable &cond()
47
 
  {
48
 
    return _end;
49
 
  }
50
 
 
51
 
  static void shutdownFirst();
52
 
  static void shutdownSecond();
53
 
 
54
 
  static void erase(const session_ptr&);
55
 
  static size_t count();
56
 
  static void insert(const session_ptr&);
57
 
 
58
 
  static session_ptr find(const session_id_t&);
 
56
  void erase(Session::Ptr);
 
57
  void erase(Session::shared_ptr&);
 
58
  size_t count();
 
59
  void insert(Session::shared_ptr &arg);
 
60
 
 
61
  Session::shared_ptr find(const session_id_t &id);
59
62
 
60
63
private:
61
 
  static bool volatile _ready_to_exit;
62
 
  static list cache;
63
 
  static boost::mutex _mutex;
64
 
  static boost::condition_variable _end;
 
64
  list cache;
 
65
  boost::mutex _mutex;
65
66
};
66
67
 
67
68
} /* namespace session */
68
69
} /* namespace drizzled */
69
70
 
 
71
#endif /* DRIZZLED_SESSION_CACHE_H */