~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/definition/cache.cc

  • Committer: Lee Bieber
  • Date: 2010-11-14 23:15:42 UTC
  • mfrom: (1929.1.42 warning-stack-frame)
  • Revision ID: kalebral@gmail.com-20101114231542-fnnu6ydd2p17n582
Merge Monty - fix bug 672372: some functions use > 32k stack

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
#include "config.h"
22
22
 
23
 
#include <boost/bind.hpp>
24
 
#include <boost/thread/mutex.hpp>
25
 
#include <boost/thread/shared_mutex.hpp>
26
 
 
 
23
#include "drizzled/pthread_globals.h"
27
24
#include "drizzled/session.h"
28
25
#include "drizzled/identifier/table.h"
29
 
#include "drizzled/definition/cache.h"
30
 
 
31
 
#include "drizzled/table/instance.h"
 
26
#include "drizzled/definition/table.h"
32
27
 
33
28
namespace drizzled {
34
29
 
35
30
namespace definition {
36
31
 
37
 
table::instance::Shared::shared_ptr Cache::find(const identifier::Table::Key &key)
 
32
TableSharePtr Cache::find(const TableIdentifier &identifier)
38
33
{
39
 
  boost::mutex::scoped_lock scopedLock(_mutex);
 
34
  //safe_mutex_assert_owner(LOCK_open.native_handle);
40
35
 
41
 
  Map::iterator iter= cache.find(key);
 
36
  CacheMap::iterator iter= cache.find(identifier.getKey());
42
37
  if (iter != cache.end())
43
38
  {
44
39
    return (*iter).second;
45
40
  }
46
41
 
47
 
  return table::instance::Shared::shared_ptr();
 
42
  return TableSharePtr();
48
43
}
49
44
 
50
 
void Cache::erase(const identifier::Table::Key &key)
 
45
void Cache::erase(const TableIdentifier &identifier)
51
46
{
52
 
  boost::mutex::scoped_lock scopedLock(_mutex);
 
47
  //safe_mutex_assert_owner(LOCK_open.native_handle);
53
48
  
54
 
  cache.erase(key);
 
49
  cache.erase(identifier.getKey());
55
50
}
56
51
 
57
 
bool Cache::insert(const identifier::Table::Key &key, table::instance::Shared::shared_ptr share)
 
52
bool Cache::insert(const TableIdentifier &identifier, TableSharePtr share)
58
53
{
59
 
  boost::mutex::scoped_lock scopedLock(_mutex);
60
 
  std::pair<Map::iterator, bool> ret=
61
 
    cache.insert(std::make_pair(key, share));
 
54
  std::pair<CacheMap::iterator, bool> ret=
 
55
    cache.insert(std::make_pair(identifier.getKey(), share));
62
56
 
63
57
  return ret.second;
64
58
}
65
59
 
66
 
void Cache::CopyFrom(drizzled::table::instance::Shared::vector &vector)
67
 
{
68
 
  boost::mutex::scoped_lock scopedLock(_mutex);
69
 
 
70
 
  vector.reserve(definition::Cache::singleton().size());
71
 
 
72
 
  std::transform(cache.begin(),
73
 
                 cache.end(),
74
 
                 std::back_inserter(vector),
75
 
                 boost::bind(&Map::value_type::second, _1) );
76
 
  assert(vector.size() == cache.size());
77
 
}
78
 
 
79
60
} /* namespace definition */
80
61
} /* namespace drizzled */