~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/message/cache.cc

  • Committer: Olaf van der Spek
  • Date: 2011-02-24 12:41:15 UTC
  • mto: (2209.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 2207.
  • Revision ID: olafvdspek@gmail.com-20110224124115-sv18p0qz5e3l7nao
UseĀ find_ptr

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include <drizzled/pthread_globals.h>
24
24
#include <drizzled/message/cache.h>
 
25
#include <drizzled/util/find_ptr.h>
25
26
 
26
27
namespace drizzled {
27
28
 
30
31
table::shared_ptr Cache::find(const identifier::Table &identifier)
31
32
{
32
33
  boost_unique_lock_t scoped_lock(_access);
33
 
 
34
 
  Map::iterator iter= cache.find(identifier.getKey());
35
 
  if (iter != cache.end())
36
 
  {
37
 
    return (*iter).second;
38
 
  }
39
 
 
 
34
  if (Map::mapped_type* i= find_ptr(cache, identifier.getKey()))
 
35
    return *i;
40
36
  return table::shared_ptr();
41
37
}
42
38
 
51
47
{
52
48
  boost_unique_lock_t scoped_lock(_access);
53
49
 
54
 
  std::pair<Map::iterator, bool> ret=
55
 
    cache.insert(std::make_pair(identifier.getKey(), share));
 
50
  std::pair<Map::iterator, bool> ret= cache.insert(std::make_pair(identifier.getKey(), share));
56
51
 
57
52
  return ret.second;
58
53
}
59
54
 
60
55
bool Cache::insert(const identifier::Table &identifier, drizzled::message::Table &message)
61
56
{
62
 
  boost_unique_lock_t scoped_lock(_access);
63
 
 
64
 
  table::shared_ptr share;
65
 
  share.reset(new message::Table(message));
66
 
 
67
 
  std::pair<Map::iterator, bool> ret=
68
 
    cache.insert(std::make_pair(identifier.getKey(), share));
69
 
 
70
 
  return ret.second;
 
57
  return insert(identifier, table::shared_ptr(new message::Table(message)));
71
58
}
72
59
 
73
60
} /* namespace definition */