00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <boost/thread/mutex.hpp>
00022 #include <boost/thread/condition_variable.hpp>
00023 #include <boost/unordered_map.hpp>
00024 #include <boost/unordered/unordered_set.hpp>
00025
00026 #include <string>
00027
00028 #include <drizzled/session.h>
00029 #include <drizzled/util/string.h>
00030
00031 #pragma once
00032
00033 namespace user_locks {
00034
00035 class Key {
00036 drizzled::identifier::User context;
00037 std::string lock_name;
00038 size_t hash_value;
00039
00040 public:
00041 Key(const drizzled::identifier::User &context_arg, const std::string &lock_name_arg) :
00042 context(context_arg),
00043 lock_name(lock_name_arg)
00044 {
00045 drizzled::util::insensitive_hash hasher;
00046 hash_value= hasher(context.username() + lock_name_arg);
00047 }
00048
00049 size_t getHashValue() const
00050 {
00051 return hash_value;
00052 }
00053
00054 const std::string &getLockName() const
00055 {
00056 return lock_name;
00057 }
00058
00059 const std::string &getUser() const
00060 {
00061 return context.username();
00062 }
00063 };
00064
00065 bool operator==(Key const& left, Key const& right);
00066
00067 std::size_t hash_value(Key const& b);
00068
00069 typedef boost::unordered_set<Key> Keys;
00070
00071 }
00072