~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-13 02:49:48 UTC
  • mto: This revision was merged to the branch mainline in revision 1853.
  • Revision ID: brian@tangent.org-20101013024948-xwel5qe6z7j21w73
Cleans up namespace for locks (now per user).

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
 
28
28
namespace user_locks {
29
29
 
30
 
bool Locks::lock(drizzled::session_id_t id_arg, const std::string &arg, int64_t wait_for)
 
30
bool Locks::lock(drizzled::session_id_t id_arg, const user_locks::Key &arg, int64_t wait_for)
31
31
{
32
32
  boost::system_time timeout= boost::get_system_time() + boost::posix_time::seconds(wait_for);
33
33
  boost::unique_lock<boost::mutex> scope(mutex);
57
57
  return false;
58
58
}
59
59
 
60
 
bool Locks::lock(drizzled::session_id_t id_arg, const std::string &arg)
 
60
bool Locks::lock(drizzled::session_id_t id_arg, const user_locks::Key &arg)
61
61
{
62
62
  std::pair<LockMap::iterator, bool> is_locked;
63
63
  boost::unique_lock<boost::mutex> scope(mutex);
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)
 
69
bool Locks::lock(drizzled::session_id_t id_arg, const user_locks::Keys &arg)
70
70
{
71
71
  boost::unique_lock<boost::mutex> scope(mutex);
72
72
 
73
 
  for (std::set< std::string >::const_iterator iter= arg.begin(); iter != arg.end(); iter++)
 
73
  for (user_locks::Keys::const_iterator iter= arg.begin(); iter != arg.end(); iter++)
74
74
  {
75
75
    LockMap::iterator record= lock_map.find(*iter);
76
76
 
81
81
    }
82
82
  }
83
83
 
84
 
  for (std::set< std::string >::iterator iter= arg.begin(); iter != arg.end(); iter++)
 
84
  for (Keys::iterator iter= arg.begin(); iter != arg.end(); iter++)
85
85
  {
86
86
    std::pair<LockMap::iterator, bool> is_locked;
87
87
    //is_locked can fail in cases where we already own the lock.
91
91
  return true;
92
92
}
93
93
 
94
 
bool Locks::isUsed(const std::string &arg, drizzled::session_id_t &id_arg)
 
94
bool Locks::isUsed(const user_locks::Key &arg, drizzled::session_id_t &id_arg)
95
95
{
96
96
  boost::unique_lock<boost::mutex> scope(mutex);
97
97
  
105
105
  return true;
106
106
}
107
107
 
108
 
bool Locks::isFree(const std::string &arg)
 
108
bool Locks::isFree(const user_locks::Key &arg)
109
109
{
110
110
  boost::unique_lock<boost::mutex> scope(mutex);
111
111
 
119
119
  lock_map_arg= lock_map;
120
120
}
121
121
 
122
 
boost::tribool Locks::release(const std::string &arg, drizzled::session_id_t &id_arg)
 
122
boost::tribool Locks::release(const user_locks::Key &arg, drizzled::session_id_t &id_arg)
123
123
{
124
124
  size_t elements= 0;
125
125
  boost::unique_lock<boost::mutex> scope(mutex);