23 #include <boost/bind.hpp>
24 #include <boost/thread/mutex.hpp>
25 #include <boost/thread/shared_mutex.hpp>
27 #include <drizzled/session.h>
28 #include <drizzled/identifier/table.h>
29 #include <drizzled/definition/cache.h>
30 #include <drizzled/table/instance.h>
31 #include <drizzled/util/find_ptr.h>
34 namespace definition {
36 Cache::Map Cache::cache;
37 boost::mutex Cache::_mutex;
39 table::instance::Shared::shared_ptr Cache::find(
const identifier::Table::Key &key)
41 boost::mutex::scoped_lock scopedLock(_mutex);
42 if (Map::mapped_type* ptr= find_ptr(cache, key))
44 return table::instance::Shared::shared_ptr();
47 void Cache::erase(
const identifier::Table::Key &key)
49 boost::mutex::scoped_lock scopedLock(_mutex);
54 bool Cache::insert(
const identifier::Table::Key &key, table::instance::Shared::shared_ptr share)
56 boost::mutex::scoped_lock scopedLock(_mutex);
57 std::pair<Map::iterator, bool> ret= cache.insert(std::make_pair(key, share));
62 void Cache::CopyFrom(drizzled::table::instance::Shared::vector &vector)
64 boost::mutex::scoped_lock scopedLock(_mutex);
66 vector.reserve(definition::Cache::size());
68 std::transform(cache.begin(), cache.end(), std::back_inserter(vector), boost::bind(&Map::value_type::second, _1));
69 assert(vector.size() == cache.size());
TODO: Rename this file - func.h is stupid.