Skip to content
This repository was archived by the owner on Mar 22, 2023. It is now read-only.

Commit c55a25b

Browse files
hashmap: run reserve() in a transaction
1 parent 4ad855c commit c55a25b

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

include/libpmemobj++/container/concurrent_hash_map.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2870,10 +2870,13 @@ class concurrent_hash_map
28702870

28712871
bool is_initial = this->size() == 0;
28722872

2873+
pool_base pop = get_pool_base();
2874+
pmem::obj::transaction::manual tx(pop);
28732875
for (size_type m = mask(); buckets > m; m = mask())
28742876
enable_segment(
28752877
segment_traits_t::segment_index_of(m + 1),
28762878
is_initial);
2879+
pmem::obj::transaction::commit();
28772880
}
28782881

28792882
/**

tests/concurrent_hash_map_tx/concurrent_hash_map_tx.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,19 @@ test_tx_singlethread(nvobj::pool<root> &pop)
276276
UT_ASSERTeq(bucket_count, map->bucket_count());
277277
verify_elements(pop, number_of_inserts);
278278

279+
/* try {
280+
pmem::obj::transaction::run(pop, [&] {
281+
map->reserve(10 * (size_t)number_of_inserts);
282+
pmem::obj::transaction::abort(0);
283+
});
284+
} catch (pmem::manual_tx_abort &) {
285+
} catch (std::exception &e) {
286+
UT_FATALexc(e);
287+
}
288+
289+
UT_ASSERTeq(bucket_count, map->bucket_count());
290+
verify_elements(pop, number_of_inserts); */
291+
279292
try {
280293
pmem::obj::transaction::run(pop, [&] {
281294
pmem::obj::delete_persistent<persistent_map_type>(map);

0 commit comments

Comments
 (0)