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

Commit be62f05

Browse files
hashmap: minor docs updates
1 parent 2df10e8 commit be62f05

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

examples/concurrent_hash_map/concurrent_hash_map.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515

1616
using namespace pmem::obj;
1717

18-
/* In this example we will be using concurrent_hash_map with p<int> type for
19-
* both keys and values */
18+
/* In this example we use concurrent_hash_map with p<int> type as
19+
* both keys and values. */
2020
using hashmap_type = concurrent_hash_map<p<int>, p<int>>;
2121

2222
const int THREADS_NUM = 30;
2323

2424
/* This is basic example and we only need to use concurrent_hash_map. Hence we
25-
* will correlate memory pool root object with single instance of persistent
26-
* pointer to hasmap_type */
25+
* correlate memory pool root object with a single instance of persistent
26+
* pointer to hashmap_type. */
2727
struct root {
2828
persistent_ptr<hashmap_type> pptr;
2929
};
@@ -73,7 +73,7 @@ main(int argc, char *argv[])
7373

7474
r->runtime_initialize();
7575

76-
/* defragment the whole pool at the beginning */
76+
/* Defragment the whole pool at the beginning. */
7777
try {
7878
r->defragment();
7979
} catch (const pmem::defrag_error &e) {
@@ -89,8 +89,8 @@ main(int argc, char *argv[])
8989
std::vector<std::thread> threads;
9090
threads.reserve(static_cast<size_t>(THREADS_NUM));
9191

92-
/* Insert THREADS_NUM / 3 key-value pairs to the hashmap. This
93-
* operation is thread-safe. */
92+
/* Start THREADS_NUM/3 threads to insert key-value pairs
93+
* to the hashmap. This operation is thread-safe. */
9494
for (int i = 0; i < THREADS_NUM / 3; ++i) {
9595
threads.emplace_back([&]() {
9696
for (int i = 0; i < 10 * THREADS_NUM; ++i) {
@@ -100,8 +100,8 @@ main(int argc, char *argv[])
100100
});
101101
}
102102

103-
/* Erase THREADS_NUM /3 key-value pairs from the hashmap. This
104-
* operation is thread-safe. */
103+
/* Start THREADS_NUM/3 threads to erase key-value pairs
104+
* from the hashmap. This operation is thread-safe. */
105105
for (int i = 0; i < THREADS_NUM / 3; ++i) {
106106
threads.emplace_back([&]() {
107107
for (int i = 0; i < 10 * THREADS_NUM; ++i) {
@@ -110,8 +110,9 @@ main(int argc, char *argv[])
110110
});
111111
}
112112

113-
/* Check if given key is in the hashmap. For the time of an
114-
* accessor life, the read-write lock is taken on the item. */
113+
/* Start THREADS_NUM/3 threads to check if given key is
114+
* in the hashmap. For the time of an accessor life,
115+
* the read-write lock is taken on the item. */
115116
for (int i = 0; i < THREADS_NUM / 3; ++i) {
116117
threads.emplace_back([&]() {
117118
for (int i = 0; i < 10 * THREADS_NUM; ++i) {
@@ -132,7 +133,7 @@ main(int argc, char *argv[])
132133
t.join();
133134
}
134135
try {
135-
/* defragment the whole pool at the end */
136+
/* Defragment the whole pool at the end. */
136137
map.defragment();
137138
} catch (const pmem::defrag_error &e) {
138139
std::cerr << "Defragmentation exception: " << e.what()
@@ -176,8 +177,7 @@ main(int argc, char *argv[])
176177
map.free_data();
177178

178179
/* map.clear() // WRONG
179-
* After free_data() concurrent hash map cannot be used
180-
* anymore! */
180+
* After free_data() hash map cannot be used anymore! */
181181

182182
transaction::run(pop, [&] {
183183
delete_persistent<hashmap_type>(r);

include/libpmemobj++/container/concurrent_hash_map.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ struct hash_map_node {
333333

334334
/**
335335
* The class provides the way to access certain properties of segments
336-
* used by hash map
336+
* used by hash map.
337337
*/
338338
template <typename Bucket>
339339
class segment_traits {
@@ -1319,7 +1319,7 @@ class hash_map_base {
13191319

13201320
/**
13211321
* Swap hash_map_base
1322-
* @throws std::transaction_error in case of PMDK transaction failed
1322+
* @throw std::transaction_error in case of PMDK transaction failed
13231323
*/
13241324
void
13251325
internal_swap(hash_map_base<Key, T, mutex_t, scoped_t> &table)
@@ -1575,7 +1575,7 @@ operator!=(const hash_map_iterator<Container, M> &i,
15751575
* Persistent memory aware implementation of Intel TBB concurrent_hash_map.
15761576
* The implementation is based on a concurrent hash table algorithm
15771577
* (https://arxiv.org/ftp/arxiv/papers/1509/1509.02235.pdf) where elements
1578-
* assigned to buckets based on a hash code are calculated from a key.
1578+
* are assigned to buckets based on a hash code calculated from a key.
15791579
* In addition to concurrent find, insert, and erase operations, the algorithm
15801580
* employs resizing and on-demand per-bucket rehashing. The hash table consists
15811581
* of an array of buckets, and each bucket consists of a list of nodes and a
@@ -2273,7 +2273,7 @@ class concurrent_hash_map
22732273
* Clear hash map content
22742274
* Not thread safe.
22752275
*
2276-
* @throws pmem::transaction_error in case of PMDK transaction failure
2276+
* @throw pmem::transaction_error in case of PMDK transaction failure
22772277
*/
22782278
void clear();
22792279

@@ -2800,7 +2800,7 @@ class concurrent_hash_map
28002800
* Remove element with corresponding key
28012801
*
28022802
* @return true if element was deleted by this call
2803-
* @throws pmem::transaction_free_error in case of PMDK unable to free
2803+
* @throw pmem::transaction_free_error in case of PMDK unable to free
28042804
* the memory
28052805
* @throw pmem::transaction_scope_error if called inside transaction
28062806
*/
@@ -2889,7 +2889,7 @@ class concurrent_hash_map
28892889
* this function without constructing an instance of Key
28902890
*
28912891
* @return true if element was deleted by this call
2892-
* @throws pmem::transaction_free_error in case of PMDK unable to free
2892+
* @throw pmem::transaction_free_error in case of PMDK unable to free
28932893
* the memory
28942894
* @throw pmem::transaction_scope_error if called inside transaction
28952895
*/

0 commit comments

Comments
 (0)