~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/session/cache.cc

  • Committer: Monty Taylor
  • Date: 2010-12-26 01:32:11 UTC
  • mto: This revision was merged to the branch mainline in revision 2038.
  • Revision ID: mordred@inaugust.com-20101226013211-c1tx52h7evovmijg
fixed dict and eval.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
#include <vector>
23
23
 
24
 
#include <drizzled/session.h>
25
 
#include <drizzled/session/cache.h>
26
 
#include <drizzled/current_session.h>
27
 
#include <drizzled/plugin/authorization.h>
 
24
#include "drizzled/session/cache.h"
 
25
#include "drizzled/session.h"
 
26
#include "drizzled/current_session.h"
 
27
#include "drizzled/plugin/authorization.h"
28
28
 
29
29
#include <boost/foreach.hpp>
30
30
 
34
34
namespace session
35
35
{
36
36
 
37
 
Cache::session_shared_ptr Cache::find(const session_id_t &id)
 
37
Session::shared_ptr Cache::find(const session_id_t &id)
38
38
{
39
39
  boost::mutex::scoped_lock scopedLock(_mutex);
40
40
 
46
46
    }
47
47
  }
48
48
 
49
 
  return session_shared_ptr();
50
 
}
51
 
 
52
 
void Cache::shutdownFirst()
53
 
{
54
 
  boost::mutex::scoped_lock scopedLock(_mutex);
55
 
  _ready_to_exit= true;
56
 
 
57
 
  /* do the broadcast inside the lock to ensure that my_end() is not called */
58
 
  _end.notify_all();
59
 
}
60
 
 
61
 
  /* Wait until cleanup is done */
62
 
void Cache::shutdownSecond()
63
 
{
64
 
  boost::mutex::scoped_lock scopedLock(_mutex);
65
 
 
66
 
  while (not _ready_to_exit)
67
 
  {
68
 
    _end.wait(scopedLock);
69
 
  }
 
49
  return Session::shared_ptr();
70
50
}
71
51
 
72
52
size_t Cache::count()
76
56
  return cache.size();
77
57
}
78
58
 
79
 
void Cache::insert(session_shared_ptr &arg)
 
59
void Cache::erase(Session::Ptr arg)
 
60
{
 
61
  BOOST_FOREACH(list::const_reference it, cache)
 
62
  {
 
63
    if (it.get() == arg)
 
64
    {
 
65
      cache.remove(it);
 
66
      return;
 
67
    }
 
68
  }
 
69
}
 
70
 
 
71
void Cache::insert(Session::shared_ptr &arg)
80
72
{
81
73
  boost::mutex::scoped_lock scopedLock(_mutex);
82
74
  cache.push_back(arg);
83
75
}
84
76
 
85
 
void Cache::erase(session_shared_ptr &arg)
 
77
void Cache::erase(Session::shared_ptr &arg)
86
78
{
87
 
  list::iterator iter= std::find(cache.begin(), cache.end(), arg);
88
 
  assert(iter != cache.end());
89
 
  cache.erase(iter);
 
79
  cache.erase(remove(cache.begin(), cache.end(), arg));
90
80
}
91
81
 
92
82
} /* namespace session */