mirror of
https://github.com/monero-project/monero.git
synced 2025-06-19 02:59:18 -04:00
switch to boost::thread for mingw build
This commit is contained in:
parent
3f171b931f
commit
2cde2c02ca
8 changed files with 69 additions and 64 deletions
|
@ -28,10 +28,9 @@
|
|||
//
|
||||
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
||||
|
||||
#include <condition_variable>
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <boost/chrono/chrono.hpp>
|
||||
#include <boost/thread/condition_variable.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
|
@ -88,13 +87,13 @@ TEST(boosted_tcp_server, worker_threads_are_exception_resistant)
|
|||
test_tcp_server srv(epee::net_utils::e_connection_type_RPC); // RPC disables network limit for unit tests
|
||||
ASSERT_TRUE(srv.init_server(test_server_port, test_server_host));
|
||||
|
||||
std::mutex mtx;
|
||||
std::condition_variable cond;
|
||||
boost::mutex mtx;
|
||||
boost::condition_variable cond;
|
||||
int counter = 0;
|
||||
|
||||
auto counter_incrementer = [&counter, &cond, &mtx]()
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mtx);
|
||||
boost::unique_lock<boost::mutex> lock(mtx);
|
||||
++counter;
|
||||
if (4 <= counter)
|
||||
{
|
||||
|
@ -110,8 +109,8 @@ TEST(boosted_tcp_server, worker_threads_are_exception_resistant)
|
|||
ASSERT_TRUE(srv.async_call([&counter_incrementer]() { counter_incrementer(); throw 4; }));
|
||||
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mtx);
|
||||
ASSERT_NE(std::cv_status::timeout, cond.wait_for(lock, std::chrono::seconds(5)));
|
||||
boost::unique_lock<boost::mutex> lock(mtx);
|
||||
ASSERT_NE(boost::cv_status::timeout, cond.wait_for(lock, boost::chrono::seconds(5)));
|
||||
ASSERT_EQ(4, counter);
|
||||
}
|
||||
|
||||
|
@ -124,8 +123,8 @@ TEST(boosted_tcp_server, worker_threads_are_exception_resistant)
|
|||
ASSERT_TRUE(srv.async_call(counter_incrementer));
|
||||
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(mtx);
|
||||
ASSERT_NE(std::cv_status::timeout, cond.wait_for(lock, std::chrono::seconds(5)));
|
||||
boost::unique_lock<boost::mutex> lock(mtx);
|
||||
ASSERT_NE(boost::cv_status::timeout, cond.wait_for(lock, boost::chrono::seconds(5)));
|
||||
ASSERT_EQ(4, counter);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue