Skip to content

Commit 8e55981

Browse files
committed
refactor: replace Boost shared_mutex with std shared_mutex in cuckoocache tests
Co-authored-by: MarcoFalke [email protected] Co-authored-by: sinetek [email protected]
1 parent f72d80b commit 8e55981

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/test/cuckoocache_tests.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
// Copyright (c) 2012-2020 The Bitcoin Core developers
22
// Distributed under the MIT software license, see the accompanying
33
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4-
#include <boost/test/unit_test.hpp>
5-
#include <boost/thread/lock_types.hpp>
6-
#include <boost/thread/shared_mutex.hpp>
74
#include <cuckoocache.h>
8-
#include <deque>
95
#include <random.h>
106
#include <script/sigcache.h>
117
#include <test/util/setup_common.h>
8+
9+
#include <boost/test/unit_test.hpp>
10+
11+
#include <deque>
12+
#include <mutex>
13+
#include <shared_mutex>
1214
#include <thread>
15+
#include <vector>
1316

1417
/** Test Suite for CuckooCache
1518
*
@@ -201,11 +204,11 @@ static void test_cache_erase_parallel(size_t megabytes)
201204
* "future proofed".
202205
*/
203206
std::vector<uint256> hashes_insert_copy = hashes;
204-
boost::shared_mutex mtx;
207+
std::shared_mutex mtx;
205208

206209
{
207210
/** Grab lock to make sure we release inserts */
208-
boost::unique_lock<boost::shared_mutex> l(mtx);
211+
std::unique_lock<std::shared_mutex> l(mtx);
209212
/** Insert the first half */
210213
for (uint32_t i = 0; i < (n_insert / 2); ++i)
211214
set.insert(hashes_insert_copy[i]);
@@ -219,7 +222,7 @@ static void test_cache_erase_parallel(size_t megabytes)
219222
/** Each thread is emplaced with x copy-by-value
220223
*/
221224
threads.emplace_back([&, x] {
222-
boost::shared_lock<boost::shared_mutex> l(mtx);
225+
std::shared_lock<std::shared_mutex> l(mtx);
223226
size_t ntodo = (n_insert/4)/3;
224227
size_t start = ntodo*x;
225228
size_t end = ntodo*(x+1);
@@ -234,7 +237,7 @@ static void test_cache_erase_parallel(size_t megabytes)
234237
for (std::thread& t : threads)
235238
t.join();
236239
/** Grab lock to make sure we observe erases */
237-
boost::unique_lock<boost::shared_mutex> l(mtx);
240+
std::unique_lock<std::shared_mutex> l(mtx);
238241
/** Insert the second half */
239242
for (uint32_t i = (n_insert / 2); i < n_insert; ++i)
240243
set.insert(hashes_insert_copy[i]);

0 commit comments

Comments
 (0)