fix coredump in link_hashmap
This commit is contained in:
8
deps/oblib/src/lib/hash/ob_dchash.h
vendored
8
deps/oblib/src/lib/hash/ob_dchash.h
vendored
@ -311,9 +311,13 @@ public:
|
||||
|
||||
int64_t count() const { return node_count_.value(); }
|
||||
Node* next(Node* node) {
|
||||
get_qsync().acquire_ref();
|
||||
while(NULL != (node = next_node(node))
|
||||
&& node->is_dummy_node())
|
||||
;
|
||||
&& node->is_dummy_node()) {
|
||||
// add usleep for dummy node test
|
||||
// usleep(1 * 1000 * 1000);
|
||||
}
|
||||
get_qsync().release_ref();
|
||||
return node;
|
||||
}
|
||||
private:
|
||||
|
||||
@ -353,6 +353,54 @@ TEST(TestObHashMap, Retire)
|
||||
delete t;
|
||||
}
|
||||
|
||||
/*
|
||||
TEST(TestObHashMap, Dummy)
|
||||
{
|
||||
struct Fn {
|
||||
bool operator()(HashKey& key, HashValue* value) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
Fn fn;
|
||||
bool stop = false;
|
||||
constexpr int64_t THREAD_COUNT = 8;
|
||||
constexpr int64_t DATA_COUNT_PER_THREAD = 81920;
|
||||
Hashmap hm(2);
|
||||
EXPECT_EQ(OB_SUCCESS, hm.init());
|
||||
std::thread insert_threads[THREAD_COUNT];
|
||||
int64_t current = 0;
|
||||
for (auto i = 0; i < THREAD_COUNT; ++i) {
|
||||
insert_threads[i] = std::thread([&]() {
|
||||
HashKey key;
|
||||
HashValue *val_ptr = nullptr;
|
||||
while (ATOMIC_LOAD(¤t) < THREAD_COUNT * DATA_COUNT_PER_THREAD) {
|
||||
key.v_ = ATOMIC_FAA(¤t, 1);
|
||||
EXPECT_EQ(OB_SUCCESS, hm.create(key, val_ptr));
|
||||
hm.revert(val_ptr);
|
||||
val_ptr = nullptr;
|
||||
}
|
||||
});
|
||||
}
|
||||
std::thread foreach_threads[THREAD_COUNT];
|
||||
for (auto i = 0; i < THREAD_COUNT; ++i) {
|
||||
foreach_threads[i] = std::thread([&]() {
|
||||
while (!stop) {
|
||||
hm.for_each(fn);
|
||||
}
|
||||
});
|
||||
}
|
||||
for (auto i = 0; i < THREAD_COUNT; ++i) {
|
||||
insert_threads[i].join();
|
||||
}
|
||||
hm.reset();
|
||||
hm.purge();
|
||||
ATOMIC_STORE(&stop, true);
|
||||
for (auto i = 0; i < THREAD_COUNT; ++i) {
|
||||
foreach_threads[i].join();
|
||||
};
|
||||
}
|
||||
*/
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
testing::InitGoogleTest(&argc,argv);
|
||||
|
||||
Reference in New Issue
Block a user