~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session/cache.h

Reverted 1103

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) 2009 Sun Microsystems, Inc.
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
19
 
 
20
 
#ifndef DRIZZLED_SESSION_CACHE_H
21
 
#define DRIZZLED_SESSION_CACHE_H
22
 
 
23
 
#include <list>
24
 
 
25
 
#include <drizzled/visibility.h>
26
 
 
27
 
namespace drizzled
28
 
{
29
 
 
30
 
class Session;
31
 
 
32
 
namespace session
33
 
{
34
 
 
35
 
class DRIZZLED_API Cache 
36
 
{
37
 
  typedef boost::shared_ptr<drizzled::Session> session_shared_ptr;
38
 
public:
39
 
  typedef std::list<session_shared_ptr> list;
40
 
 
41
 
  Cache() :
42
 
    _ready_to_exit(false)
43
 
  {
44
 
  }
45
 
 
46
 
  static inline Cache &singleton()
47
 
  {
48
 
    static Cache open_cache;
49
 
 
50
 
    return open_cache;
51
 
  }
52
 
 
53
 
  list &getCache()
54
 
  {
55
 
    return cache;
56
 
  }
57
 
 
58
 
  boost::mutex &mutex()
59
 
  {
60
 
    return _mutex;
61
 
  }
62
 
 
63
 
  boost::condition_variable &cond()
64
 
  {
65
 
    return _end;
66
 
  }
67
 
 
68
 
  void shutdownFirst();
69
 
  void shutdownSecond();
70
 
 
71
 
  void erase(session_shared_ptr&);
72
 
  size_t count();
73
 
  void insert(session_shared_ptr &arg);
74
 
 
75
 
  session_shared_ptr find(const session_id_t &id);
76
 
 
77
 
private:
78
 
  bool volatile _ready_to_exit;
79
 
  list cache;
80
 
  boost::mutex _mutex;
81
 
  boost::condition_variable _end;
82
 
};
83
 
 
84
 
} /* namespace session */
85
 
} /* namespace drizzled */
86
 
 
87
 
#endif /* DRIZZLED_SESSION_CACHE_H */