mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
refactor: replace Boost shared_mutex with std shared_mutex in cuckoocache tests
Co-authored-by: MarcoFalke falke.marco@gmail.com Co-authored-by: sinetek pitwuu@gmail.com
This commit is contained in:
parent
f72d80b07a
commit
8e55981ef8
1 changed files with 11 additions and 8 deletions
|
@ -1,15 +1,18 @@
|
|||
// Copyright (c) 2012-2020 The Bitcoin Core developers
|
||||
// Distributed under the MIT software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
#include <boost/test/unit_test.hpp>
|
||||
#include <boost/thread/lock_types.hpp>
|
||||
#include <boost/thread/shared_mutex.hpp>
|
||||
#include <cuckoocache.h>
|
||||
#include <deque>
|
||||
#include <random.h>
|
||||
#include <script/sigcache.h>
|
||||
#include <test/util/setup_common.h>
|
||||
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <deque>
|
||||
#include <mutex>
|
||||
#include <shared_mutex>
|
||||
#include <thread>
|
||||
#include <vector>
|
||||
|
||||
/** Test Suite for CuckooCache
|
||||
*
|
||||
|
@ -201,11 +204,11 @@ static void test_cache_erase_parallel(size_t megabytes)
|
|||
* "future proofed".
|
||||
*/
|
||||
std::vector<uint256> hashes_insert_copy = hashes;
|
||||
boost::shared_mutex mtx;
|
||||
std::shared_mutex mtx;
|
||||
|
||||
{
|
||||
/** Grab lock to make sure we release inserts */
|
||||
boost::unique_lock<boost::shared_mutex> l(mtx);
|
||||
std::unique_lock<std::shared_mutex> l(mtx);
|
||||
/** Insert the first half */
|
||||
for (uint32_t i = 0; i < (n_insert / 2); ++i)
|
||||
set.insert(hashes_insert_copy[i]);
|
||||
|
@ -219,7 +222,7 @@ static void test_cache_erase_parallel(size_t megabytes)
|
|||
/** Each thread is emplaced with x copy-by-value
|
||||
*/
|
||||
threads.emplace_back([&, x] {
|
||||
boost::shared_lock<boost::shared_mutex> l(mtx);
|
||||
std::shared_lock<std::shared_mutex> l(mtx);
|
||||
size_t ntodo = (n_insert/4)/3;
|
||||
size_t start = ntodo*x;
|
||||
size_t end = ntodo*(x+1);
|
||||
|
@ -234,7 +237,7 @@ static void test_cache_erase_parallel(size_t megabytes)
|
|||
for (std::thread& t : threads)
|
||||
t.join();
|
||||
/** Grab lock to make sure we observe erases */
|
||||
boost::unique_lock<boost::shared_mutex> l(mtx);
|
||||
std::unique_lock<std::shared_mutex> l(mtx);
|
||||
/** Insert the second half */
|
||||
for (uint32_t i = (n_insert / 2); i < n_insert; ++i)
|
||||
set.insert(hashes_insert_copy[i]);
|
||||
|
|
Loading…
Add table
Reference in a new issue