~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session/cache.h

  • Committer: Stewart Smith
  • Date: 2011-01-14 05:18:23 UTC
  • mto: (2086.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 2087.
  • Revision ID: stewart@flamingspork.com-20110114051823-14fyn2kvg8pc5a15
\r and trailing whitespace removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2009 Sun Microsystems
 
4
 *  Copyright (C) 2009 Sun Microsystems, Inc.
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#ifndef DRIZZLED_SESSION_LIST_H
21
 
#define DRIZZLED_SESSION_LIST_H
 
20
#ifndef DRIZZLED_SESSION_CACHE_H
 
21
#define DRIZZLED_SESSION_CACHE_H
22
22
 
23
 
#include <vector>
 
23
#include "drizzled/session.h"
 
24
#include <list>
24
25
 
25
26
namespace drizzled
26
27
{
27
28
 
28
29
class Session;
29
 
typedef std::vector<Session *> SessionList;
30
 
SessionList &getSessionList();
31
 
 
32
 
}
33
 
 
34
 
#endif /* DRIZZLED_SESSION_LIST_H */
 
30
 
 
31
namespace session
 
32
{
 
33
 
 
34
class Cache 
 
35
{
 
36
public:
 
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()
 
47
  {
 
48
    return cache;
 
49
  }
 
50
 
 
51
  boost::mutex &mutex()
 
52
  {
 
53
    return _mutex;
 
54
  }
 
55
 
 
56
  void erase(Session::shared_ptr&);
 
57
  size_t count();
 
58
  void insert(Session::shared_ptr &arg);
 
59
 
 
60
  Session::shared_ptr find(const session_id_t &id);
 
61
 
 
62
private:
 
63
  list cache;
 
64
  boost::mutex _mutex;
 
65
};
 
66
 
 
67
} /* namespace session */
 
68
} /* namespace drizzled */
 
69
 
 
70
#endif /* DRIZZLED_SESSION_CACHE_H */