~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/user_locks/locks.cc

  • Committer: Brian Aker
  • Date: 2010-10-12 19:16:24 UTC
  • mto: This revision was merged to the branch mainline in revision 1853.
  • Revision ID: brian@tangent.org-20101012191624-4tj8lzjsksn5xwu5
Added get_locks() and release_locks();

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
  return is_locked.second;
67
67
}
68
68
 
 
69
bool Locks::lock(drizzled::session_id_t id_arg, const std::set< std::string > &arg)
 
70
{
 
71
  boost::unique_lock<boost::mutex> scope(mutex);
 
72
 
 
73
  for (std::set< std::string >::const_iterator iter= arg.begin(); iter != arg.end(); iter++)
 
74
  {
 
75
    LockMap::iterator record= lock_map.find(*iter);
 
76
 
 
77
    if (record != lock_map.end())
 
78
    {
 
79
      if (id_arg != (*record).second->id)
 
80
        return false;
 
81
    }
 
82
  }
 
83
 
 
84
  for (std::set< std::string >::iterator iter= arg.begin(); iter != arg.end(); iter++)
 
85
  {
 
86
    std::pair<LockMap::iterator, bool> is_locked;
 
87
    //is_locked can fail in cases where we already own the lock.
 
88
    is_locked= lock_map.insert(std::make_pair(*iter, new lock_st(id_arg)));
 
89
  }
 
90
 
 
91
  return true;
 
92
}
 
93
 
69
94
bool Locks::isUsed(const std::string &arg, drizzled::session_id_t &id_arg)
70
95
{
71
96
  boost::unique_lock<boost::mutex> scope(mutex);