27 #ifndef API_LOCK_STL_H_
28 #define API_LOCK_STL_H_
30 #include <boost/thread.hpp>
31 #include <unordered_map>
32 #include <tr1/unordered_map>
34 template<
class Key,
class Value>
38 struct s_hash :
public std::unary_function<T, std::size_t> {
41 char * temp = (
char *)(&k);
42 for (
int i = 0; i <
sizeof(Key); i++) {
52 template <
class T>
struct equal_to : std::binary_function <T,T,bool> {
55 bool res = memcmp(&x, &y,
sizeof(Key)) == 0;
61 typedef typename std::tr1::unordered_map<Key, Value, c_hash, c_equals, std::allocator<std::pair<Key, Value> > >
hash_t;
69 return "Locked STL Map";
77 boost::mutex::scoped_lock lock(
v_mutex);
89 boost::mutex::scoped_lock lock(
v_mutex);
90 std::pair<typename hash_t::iterator, bool> res =
test_container->insert(std::make_pair(key,value));
96 boost::mutex::scoped_lock lock(
v_mutex);
100 if (iter->second == value_expected) {
101 iter->second = value_new;
104 value_expected = iter->second;
112 bool remove(Key key) {
113 boost::mutex::scoped_lock lock(
v_mutex);
129 #endif //API_LOCK_STL_H_
struct equal_to< Value > c_equals
Definition: lock_boost_map.h:58
void detach_thread()
Definition: lock_stl_map.h:74
bool operator()(const T &x, const T &y) const
Definition: lock_boost_map.h:52
bool insert(Key key, Value value)
Definition: lock_stl_map.h:88
std::tr1::unordered_map< Key, Value, c_hash, c_equals, std::allocator< std::pair< Key, Value > > > hash_t
Definition: lock_stl_map.h:61
cds::container::MichaelHashMap< cds::gc::HP, Key2Value_list, map_traits > hash_t
Definition: cds_michael_map.h:70
void attach_thread()
Definition: lock_stl_map.h:72
hash_t * test_container
Definition: cds_michael_map.h:158
struct s_hash< Value > c_hash
Definition: lock_boost_map.h:49
bool update(Key key, Value &value_expected, Value value_new)
Definition: lock_stl_map.h:95
uint64_t Value
Definition: testObject.h:59
size_t size()
Definition: lock_stl_map.h:119
bool find(Key key, Value &value)
Definition: lock_stl_map.h:76
Definition: blank_api.h:31
TestClass(size_t num_threads, size_t capacity)
Definition: lock_stl_map.h:63
boost::mutex v_mutex
Definition: lock_boost_map.h:122
std::size_t operator()(T const &k) const
Definition: lock_stl_map.h:39
std::string toString()
Definition: lock_stl_map.h:68