aboutsummaryrefslogtreecommitdiff
path: root/tests/net_load_tests
diff options
context:
space:
mode:
authorLee Clagett <code@leeclagett.com>2017-02-12 17:53:13 -0500
committerLee Clagett <code@leeclagett.com>2017-02-16 20:10:23 -0500
commit2cde2c02ca0e2bf1dc6f8fa78cd830f5989f9cea (patch)
treee0fb13b6e69c139e0cdf4557bc9fa99b7d492d81 /tests/net_load_tests
parentMerge pull request #1719 (diff)
downloadmonero-2cde2c02ca0e2bf1dc6f8fa78cd830f5989f9cea.tar.xz
switch to boost::thread for mingw build
Diffstat (limited to 'tests/net_load_tests')
-rw-r--r--tests/net_load_tests/CMakeLists.txt1
-rw-r--r--tests/net_load_tests/clt.cpp8
-rw-r--r--tests/net_load_tests/srv.cpp14
3 files changed, 12 insertions, 11 deletions
diff --git a/tests/net_load_tests/CMakeLists.txt b/tests/net_load_tests/CMakeLists.txt
index 4db44f25a..492a6bdea 100644
--- a/tests/net_load_tests/CMakeLists.txt
+++ b/tests/net_load_tests/CMakeLists.txt
@@ -44,6 +44,7 @@ target_link_libraries(net_load_tests_clt
${Boost_CHRONO_LIBRARY}
${Boost_DATE_TIME_LIBRARY}
${Boost_SYSTEM_LIBRARY}
+ ${Boost_THREAD_LIBARRY}
${CMAKE_THREAD_LIBS_INIT}
${EXTRA_LIBRARIES})
diff --git a/tests/net_load_tests/clt.cpp b/tests/net_load_tests/clt.cpp
index 39e8794b1..90f0014a5 100644
--- a/tests/net_load_tests/clt.cpp
+++ b/tests/net_load_tests/clt.cpp
@@ -32,7 +32,7 @@
#include <chrono>
#include <functional>
#include <numeric>
-#include <thread>
+#include <boost/thread/thread.hpp>
#include <vector>
#include "gtest/gtest.h"
@@ -191,7 +191,7 @@ namespace
protected:
virtual void SetUp()
{
- m_thread_count = (std::max)(min_thread_count, std::thread::hardware_concurrency() / 2);
+ m_thread_count = (std::max)(min_thread_count, boost::thread::hardware_concurrency() / 2);
m_tcp_server.get_config_object().m_pcommands_handler = &m_commands_handler;
m_tcp_server.get_config_object().m_invoke_timeout = CONNECTION_TIMEOUT;
@@ -278,10 +278,10 @@ namespace
void parallel_exec(const Func& func)
{
unit_test::call_counter properly_finished_threads;
- std::vector<std::thread> threads(m_thread_count);
+ std::vector<boost::thread> threads(m_thread_count);
for (size_t i = 0; i < threads.size(); ++i)
{
- threads[i] = std::thread([&, i] {
+ threads[i] = boost::thread([&, i] {
call_func(i, func, 0);
properly_finished_threads.inc();
});
diff --git a/tests/net_load_tests/srv.cpp b/tests/net_load_tests/srv.cpp
index 3bbbeef7f..0ccc743d9 100644
--- a/tests/net_load_tests/srv.cpp
+++ b/tests/net_load_tests/srv.cpp
@@ -28,8 +28,8 @@
//
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
-#include <mutex>
-#include <thread>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/thread.hpp>
#include "include_base_utils.h"
#include "misc_log_ex.h"
@@ -58,7 +58,7 @@ namespace
//std::this_thread::sleep_for(std::chrono::milliseconds(10));
- std::unique_lock<std::mutex> lock(m_open_close_test_mutex);
+ boost::unique_lock<boost::mutex> lock(m_open_close_test_mutex);
if (!m_open_close_test_conn_id.is_nil())
{
EXIT_ON_ERROR(m_open_close_test_helper->handle_new_connection(context.m_connection_id, true));
@@ -69,7 +69,7 @@ namespace
{
test_levin_commands_handler::on_connection_close(context);
- std::unique_lock<std::mutex> lock(m_open_close_test_mutex);
+ boost::unique_lock<boost::mutex> lock(m_open_close_test_mutex);
if (context.m_connection_id == m_open_close_test_conn_id)
{
LOG_PRINT_L0("Stop open/close test");
@@ -115,7 +115,7 @@ namespace
int handle_start_open_close_test(int command, const CMD_START_OPEN_CLOSE_TEST::request& req, CMD_START_OPEN_CLOSE_TEST::response&, test_connection_context& context)
{
- std::unique_lock<std::mutex> lock(m_open_close_test_mutex);
+ boost::unique_lock<boost::mutex> lock(m_open_close_test_mutex);
if (0 == m_open_close_test_helper.get())
{
LOG_PRINT_L0("Start open/close test (" << req.open_request_target << ", " << req.max_opened_conn_count << ")");
@@ -208,7 +208,7 @@ namespace
test_tcp_server& m_tcp_server;
boost::uuids::uuid m_open_close_test_conn_id;
- std::mutex m_open_close_test_mutex;
+ boost::mutex m_open_close_test_mutex;
std::unique_ptr<open_close_test_helper> m_open_close_test_helper;
};
}
@@ -218,7 +218,7 @@ int main(int argc, char** argv)
//set up logging options
mlog_configure(mlog_get_default_log_path("net_load_tests_srv.log"), true);
- size_t thread_count = (std::max)(min_thread_count, std::thread::hardware_concurrency() / 2);
+ size_t thread_count = (std::max)(min_thread_count, boost::thread::hardware_concurrency() / 2);
test_tcp_server tcp_server(epee::net_utils::e_connection_type_RPC);
if (!tcp_server.init_server(srv_port, "127.0.0.1"))