mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-12 12:52:35 -03:00
test: Replace boost::mutex with std::mutex
This commit is contained in:
parent
895c71e535
commit
27abd1a4f4
1 changed files with 5 additions and 3 deletions
|
@ -9,12 +9,14 @@
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
|
|
||||||
|
#include <mutex>
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE(scheduler_tests)
|
BOOST_AUTO_TEST_SUITE(scheduler_tests)
|
||||||
|
|
||||||
static void microTask(CScheduler& s, boost::mutex& mutex, int& counter, int delta, std::chrono::system_clock::time_point rescheduleTime)
|
static void microTask(CScheduler& s, std::mutex& mutex, int& counter, int delta, std::chrono::system_clock::time_point rescheduleTime)
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> lock(mutex);
|
std::lock_guard<std::mutex> lock(mutex);
|
||||||
counter += delta;
|
counter += delta;
|
||||||
}
|
}
|
||||||
std::chrono::system_clock::time_point noTime = std::chrono::system_clock::time_point::min();
|
std::chrono::system_clock::time_point noTime = std::chrono::system_clock::time_point::min();
|
||||||
|
@ -38,7 +40,7 @@ BOOST_AUTO_TEST_CASE(manythreads)
|
||||||
// counters should sum to the number of initial tasks performed.
|
// counters should sum to the number of initial tasks performed.
|
||||||
CScheduler microTasks;
|
CScheduler microTasks;
|
||||||
|
|
||||||
boost::mutex counterMutex[10];
|
std::mutex counterMutex[10];
|
||||||
int counter[10] = { 0 };
|
int counter[10] = { 0 };
|
||||||
FastRandomContext rng{/* fDeterministic */ true};
|
FastRandomContext rng{/* fDeterministic */ true};
|
||||||
auto zeroToNine = [](FastRandomContext& rc) -> int { return rc.randrange(10); }; // [0, 9]
|
auto zeroToNine = [](FastRandomContext& rc) -> int { return rc.randrange(10); }; // [0, 9]
|
||||||
|
|
Loading…
Reference in a new issue