27 #ifndef API_LOCK_BOOST_H_
28 #define API_LOCK_BOOST_H_
30 #include <boost/thread.hpp>
31 #include <boost/unordered_map.hpp>
33 template<
class Key,
class Value>
37 struct s_hash :
public std::unary_function<T, std::size_t> {
40 char * temp = (
char *)(&k);
41 for (
int i = 0; i <
sizeof(Key); i++) {
51 template <
class T>
struct equal_to : std::binary_function <T,T,bool> {
54 bool res = memcmp(&x, &y,
sizeof(Key)) == 0;
60 typedef typename boost::unordered_map<Key, Value, c_hash, c_equals, std::allocator<std::pair<Key, Value> > >
hash_t;
69 return "Locked Boost 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));
95 boost::mutex::scoped_lock lock(
v_mutex);
99 if (iter->second == value_expected) {
100 iter->second = value_new;
103 value_expected = iter->second;
110 bool remove(Key key) {
111 boost::mutex::scoped_lock lock(
v_mutex);
127 #endif //API_LOCK_BOOST_H_
struct equal_to< Value > c_equals
Definition: lock_boost_map.h:58
void detach_thread()
Definition: lock_boost_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_boost_map.h:88
boost::unordered_map< Key, Value, c_hash, c_equals, std::allocator< std::pair< Key, Value > > > hash_t
Definition: lock_boost_map.h:60
Definition: lock_boost_map.h:51
cds::container::MichaelHashMap< cds::gc::HP, Key2Value_list, map_traits > hash_t
Definition: cds_michael_map.h:70
void attach_thread()
Definition: lock_boost_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_boost_map.h:94
uint64_t Value
Definition: testObject.h:59
size_t size()
Definition: lock_boost_map.h:117
bool find(Key key, Value &value)
Definition: lock_boost_map.h:76
Definition: blank_api.h:31
TestClass(size_t num_threads, size_t capacity)
Definition: lock_boost_map.h:63
boost::mutex v_mutex
Definition: lock_boost_map.h:122
std::size_t operator()(T const &k) const
Definition: lock_boost_map.h:38
std::string toString()
Definition: lock_boost_map.h:68