~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/user_locks/locks.h

  • Committer: Brian Aker
  • Date: 2010-11-27 13:38:27 UTC
  • mfrom: (1955.1.3 quick)
  • Revision ID: brian@tangent.org-20101127133827-fowoi26sizq1zneg
Rollup of staging, mostly UDL

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include <boost/thread/mutex.hpp>
22
22
#include <boost/thread/condition_variable.hpp>
23
23
#include <boost/unordered_map.hpp>
24
 
#include <boost/logic/tribool.hpp>
25
24
#include <boost/unordered/unordered_set.hpp>
26
25
 
27
26
#include "plugin/user_locks/lock.h"
37
36
 
38
37
namespace user_locks {
39
38
 
 
39
namespace locks {
 
40
  enum return_t {
 
41
    SUCCESS,
 
42
    NOT_FOUND,
 
43
    NOT_OWNED_BY
 
44
  };
 
45
} /* locks user_locks */
 
46
 
40
47
const size_t LARGEST_LOCK_NAME= 64;
41
48
 
42
49
class Locks
50
57
    return instance;
51
58
  }
52
59
 
53
 
  bool lock(drizzled::session_id_t id_arg, const user_locks::Key &arg);
 
60
  void waitCreate(int64_t wait_for= 2); // Default is to wait 2 seconds before returning
 
61
 
54
62
  bool lock(drizzled::session_id_t id_arg, const user_locks::Key &arg, int64_t wait_for= 0);
55
63
  bool lock(drizzled::session_id_t id_arg, const user_locks::Keys &arg);
56
 
  boost::tribool release(const user_locks::Key &arg, drizzled::session_id_t &id_arg);
 
64
  locks::return_t release(const user_locks::Key &arg, drizzled::session_id_t &id_arg, bool and_wait= false);
57
65
  bool isFree(const user_locks::Key &arg);
58
66
  bool isUsed(const user_locks::Key &arg, drizzled::session_id_t &id_arg);
59
67
  void Copy(LockMap &lock_map);
60
68
 
61
69
private:
62
70
  boost::mutex mutex;
63
 
  boost::condition_variable cond;
 
71
  boost::condition_variable create_cond; // Signal next 
 
72
  boost::condition_variable release_cond;
64
73
  LockMap lock_map; 
65
74
};
66
75