1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2009 Sun Microsystems, Inc.
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.
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.
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
24
#include <drizzled/session.h>
25
#include <drizzled/session/cache.h>
26
#include <drizzled/current_session.h>
27
#include <drizzled/plugin/authorization.h>
29
#include <boost/foreach.hpp>
37
Cache::session_shared_ptr Cache::find(const session_id_t &id)
39
boost::mutex::scoped_lock scopedLock(_mutex);
41
BOOST_FOREACH(list::const_reference it, cache)
43
if (it->thread_id == id)
49
return session_shared_ptr();
52
void Cache::shutdownFirst()
54
boost::mutex::scoped_lock scopedLock(_mutex);
57
/* do the broadcast inside the lock to ensure that my_end() is not called */
61
/* Wait until cleanup is done */
62
void Cache::shutdownSecond()
64
boost::mutex::scoped_lock scopedLock(_mutex);
66
while (not _ready_to_exit)
68
_end.wait(scopedLock);
74
boost::mutex::scoped_lock scopedLock(_mutex);
79
void Cache::insert(session_shared_ptr &arg)
81
boost::mutex::scoped_lock scopedLock(_mutex);
85
void Cache::erase(session_shared_ptr &arg)
87
list::iterator iter= std::find(cache.begin(), cache.end(), arg);
88
assert(iter != cache.end());
92
} /* namespace session */
93
} /* namespace drizzled */