mirror of https://github.com/oxen-io/oxen-core.git
boost->std: mutex, locks; C++17 lock vars
Changes all boost mutexes, locks, and condition_variables to their stl equivalents. Changes all lock_guard/unique_lock/shared_lock to not specify the mutex type (C++17), e.g. std::lock_guard foo{mutex}; instead of std::lock_guard<oh::um::what::mutex> foo{mutex}; Also changes some related boost::thread calls to std::thread, and some related boost chrono calls to stl chrono. boost::thread isn't changed here to std::thread because some of the instances rely on some boost thread extensions.
This commit is contained in:
parent
96354a0e0f
commit
e02545ca4b
|
@ -29,8 +29,8 @@
|
|||
#pragma once
|
||||
|
||||
#include <limits>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/chrono/duration.hpp>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include <memory>
|
||||
|
||||
namespace epee
|
||||
|
@ -99,7 +99,7 @@ namespace misc_utils
|
|||
inline
|
||||
void sleep_no_w(long ms)
|
||||
{
|
||||
boost::this_thread::sleep_for(boost::chrono::milliseconds{ms});
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds{ms});
|
||||
}
|
||||
|
||||
template<class type_vec_type>
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <mutex>
|
||||
#include "span.h"
|
||||
|
||||
namespace epee
|
||||
|
@ -51,7 +51,7 @@ namespace epee
|
|||
static size_t page_size;
|
||||
static size_t num_locked_objects;
|
||||
|
||||
static boost::mutex &mutex();
|
||||
static std::mutex &mutex();
|
||||
static std::map<size_t, unsigned int> &map();
|
||||
static void lock_page(size_t page);
|
||||
static void unlock_page(size_t page);
|
||||
|
|
|
@ -185,8 +185,8 @@ namespace net_utils
|
|||
// for calculate speed (last 60 sec)
|
||||
network_throttle m_throttle_speed_in;
|
||||
network_throttle m_throttle_speed_out;
|
||||
boost::mutex m_throttle_speed_in_mutex;
|
||||
boost::mutex m_throttle_speed_out_mutex;
|
||||
std::mutex m_throttle_speed_in_mutex;
|
||||
std::mutex m_throttle_speed_out_mutex;
|
||||
|
||||
boost::asio::deadline_timer m_timer;
|
||||
bool m_local;
|
||||
|
@ -397,7 +397,7 @@ namespace net_utils
|
|||
connection_ptr new_connection_ipv6;
|
||||
|
||||
|
||||
boost::mutex connections_mutex;
|
||||
std::mutex connections_mutex;
|
||||
std::set<connection_ptr> connections_;
|
||||
}; // class <>boosted_tcp_server
|
||||
|
||||
|
|
|
@ -37,13 +37,14 @@
|
|||
#include <boost/chrono.hpp>
|
||||
#include <boost/asio/deadline_timer.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp> // TODO
|
||||
#include <boost/thread/condition_variable.hpp> // TODO
|
||||
#include "warnings.h"
|
||||
#include "string_tools.h"
|
||||
#include "misc_language.h"
|
||||
#include "net/local_ip.h"
|
||||
#include "pragma_comp_defs.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <algorithm>
|
||||
|
@ -732,7 +733,7 @@ PRAGMA_WARNING_DISABLE_VS(4355)
|
|||
template<class t_protocol_handler>
|
||||
unsigned int connection<t_protocol_handler>::host_count(const std::string &host, int delta)
|
||||
{
|
||||
static boost::mutex hosts_mutex;
|
||||
static std::mutex hosts_mutex;
|
||||
CRITICAL_REGION_LOCAL(hosts_mutex);
|
||||
static std::map<std::string, unsigned int> hosts;
|
||||
unsigned int &val = hosts[host];
|
||||
|
@ -1109,7 +1110,7 @@ POP_WARNINGS
|
|||
TRY_ENTRY();
|
||||
uint32_t local_thr_index = boost::interprocess::ipcdetail::atomic_inc32(&m_thread_index);
|
||||
std::string thread_name = std::string("[") + m_thread_name_prefix;
|
||||
thread_name += boost::to_string(local_thr_index) + "]";
|
||||
thread_name += std::to_string(local_thr_index) + "]";
|
||||
MLOG_SET_THREAD_NAME(thread_name);
|
||||
// _fact("Thread name: " << m_thread_name_prefix);
|
||||
while(!m_stop_signal_sent)
|
||||
|
@ -1390,13 +1391,13 @@ POP_WARNINGS
|
|||
struct local_async_context
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
boost::mutex connect_mut;
|
||||
boost::condition_variable cond;
|
||||
std::mutex connect_mut;
|
||||
std::condition_variable cond;
|
||||
};
|
||||
|
||||
std::shared_ptr<local_async_context> local_shared_context(new local_async_context());
|
||||
local_shared_context->ec = boost::asio::error::would_block;
|
||||
boost::unique_lock<boost::mutex> lock(local_shared_context->connect_mut);
|
||||
std::unique_lock lock{local_shared_context->connect_mut};
|
||||
auto connect_callback = [](boost::system::error_code ec_, std::shared_ptr<local_async_context> shared_context)
|
||||
{
|
||||
shared_context->connect_mut.lock(); shared_context->ec = ec_; shared_context->cond.notify_one(); shared_context->connect_mut.unlock();
|
||||
|
@ -1405,14 +1406,14 @@ POP_WARNINGS
|
|||
sock_.async_connect(remote_endpoint, boost::bind<void>(connect_callback, _1, local_shared_context));
|
||||
while(local_shared_context->ec == boost::asio::error::would_block)
|
||||
{
|
||||
bool r = local_shared_context->cond.timed_wait(lock, boost::get_system_time() + boost::posix_time::milliseconds(conn_timeout));
|
||||
auto wait_stat = local_shared_context->cond.wait_for(lock, std::chrono::milliseconds{conn_timeout});
|
||||
if (m_stop_signal_sent)
|
||||
{
|
||||
if (sock_.is_open())
|
||||
sock_.close();
|
||||
return CONNECT_FAILURE;
|
||||
}
|
||||
if(local_shared_context->ec == boost::asio::error::would_block && !r)
|
||||
if(local_shared_context->ec == boost::asio::error::would_block && wait_stat == std::cv_status::timeout)
|
||||
{
|
||||
//timeout
|
||||
sock_.close();
|
||||
|
|
|
@ -37,36 +37,8 @@
|
|||
#ifndef INCLUDED_network_throttle_hpp
|
||||
#define INCLUDED_network_throttle_hpp
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <atomic>
|
||||
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/interprocess/detail/atomic.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
|
||||
#include "syncobj.h"
|
||||
|
||||
#include "net/net_utils_base.h"
|
||||
#include "misc_log_ex.h"
|
||||
#include <boost/lambda/bind.hpp>
|
||||
#include <boost/lambda/lambda.hpp>
|
||||
#include <boost/uuid/random_generator.hpp>
|
||||
#include <boost/chrono.hpp>
|
||||
#include <boost/asio/deadline_timer.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include "misc_language.h"
|
||||
#include "pragma_comp_defs.h"
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <algorithm>
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <fstream>
|
||||
|
||||
namespace epee
|
||||
{
|
||||
|
@ -105,9 +77,9 @@ class network_throttle_manager {
|
|||
//protected:
|
||||
public: // XXX
|
||||
|
||||
static boost::mutex m_lock_get_global_throttle_in;
|
||||
static boost::mutex m_lock_get_global_throttle_inreq;
|
||||
static boost::mutex m_lock_get_global_throttle_out;
|
||||
static std::mutex m_lock_get_global_throttle_in;
|
||||
static std::mutex m_lock_get_global_throttle_inreq;
|
||||
static std::mutex m_lock_get_global_throttle_out;
|
||||
|
||||
friend class connection_basic; // FRIEND - to directly access global throttle-s. !! REMEMBER TO USE LOCKS!
|
||||
friend class connection_basic_pimpl; // ditto
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
#ifndef _PROFILE_TOOLS_H_
|
||||
#define _PROFILE_TOOLS_H_
|
||||
|
||||
#include "misc_os_dependent.h"
|
||||
#include <chrono>
|
||||
|
||||
namespace epee
|
||||
{
|
||||
|
@ -90,26 +90,26 @@ namespace profile_tools
|
|||
call_frame(local_call_account& cc):m_cc(cc)
|
||||
{
|
||||
cc.m_count_of_call++;
|
||||
m_call_time = boost::posix_time::microsec_clock::local_time();
|
||||
m_call_time = std::chrono::steady_clock::now();
|
||||
//::QueryPerformanceCounter((LARGE_INTEGER *)&m_call_time);
|
||||
}
|
||||
|
||||
~call_frame()
|
||||
{
|
||||
//__int64 ret_time = 0;
|
||||
|
||||
boost::posix_time::ptime now_t(boost::posix_time::microsec_clock::local_time());
|
||||
boost::posix_time::time_duration delta_microsec = now_t - m_call_time;
|
||||
uint64_t miliseconds_used = delta_microsec.total_microseconds();
|
||||
|
||||
auto elapsed = std::chrono::steady_clock::now() - m_call_time;
|
||||
uint64_t useconds_used = static_cast<uint64_t>(
|
||||
std::chrono::duration_cast<std::chrono::microseconds>(elapsed).count());
|
||||
|
||||
//::QueryPerformanceCounter((LARGE_INTEGER *)&ret_time);
|
||||
//m_call_time = (ret_time-m_call_time)/1000;
|
||||
m_cc.m_summary_time_used += miliseconds_used;
|
||||
m_cc.m_summary_time_used += useconds_used;
|
||||
}
|
||||
|
||||
private:
|
||||
local_call_account& m_cc;
|
||||
boost::posix_time::ptime m_call_time;
|
||||
std::chrono::steady_clock::time_point m_call_time;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -30,12 +30,10 @@
|
|||
#ifndef __WINH_OBJ_H__
|
||||
#define __WINH_OBJ_H__
|
||||
|
||||
#include <boost/chrono/duration.hpp>
|
||||
#include <boost/thread/condition_variable.hpp>
|
||||
#include <boost/thread/locks.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/recursive_mutex.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <chrono>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
namespace epee
|
||||
{
|
||||
|
@ -57,22 +55,24 @@ namespace epee
|
|||
|
||||
void raise()
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(m_mx);
|
||||
m_rised = true;
|
||||
{
|
||||
std::lock_guard lock{m_mx};
|
||||
m_rised = true;
|
||||
}
|
||||
m_cond_var.notify_one();
|
||||
}
|
||||
|
||||
void wait()
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(m_mx);
|
||||
std::unique_lock lock(m_mx);
|
||||
while (!m_rised)
|
||||
m_cond_var.wait(lock);
|
||||
m_rised = false;
|
||||
}
|
||||
|
||||
private:
|
||||
boost::mutex m_mx;
|
||||
boost::condition_variable m_cond_var;
|
||||
std::mutex m_mx;
|
||||
std::condition_variable m_cond_var;
|
||||
bool m_rised;
|
||||
};
|
||||
|
||||
|
@ -80,7 +80,7 @@ namespace epee
|
|||
|
||||
class critical_section
|
||||
{
|
||||
boost::recursive_mutex m_section;
|
||||
std::recursive_mutex m_section;
|
||||
|
||||
public:
|
||||
//to make copy fake!
|
||||
|
@ -151,9 +151,9 @@ namespace epee
|
|||
|
||||
|
||||
#define CRITICAL_REGION_LOCAL(x) {} epee::critical_region_t<decltype(x)> critical_region_var(x)
|
||||
#define CRITICAL_REGION_BEGIN(x) { boost::this_thread::sleep_for(boost::chrono::milliseconds(epee::debug::g_test_dbg_lock_sleep())); epee::critical_region_t<decltype(x)> critical_region_var(x)
|
||||
#define CRITICAL_REGION_LOCAL1(x) {boost::this_thread::sleep_for(boost::chrono::milliseconds(epee::debug::g_test_dbg_lock_sleep()));} epee::critical_region_t<decltype(x)> critical_region_var1(x)
|
||||
#define CRITICAL_REGION_BEGIN1(x) { boost::this_thread::sleep_for(boost::chrono::milliseconds(epee::debug::g_test_dbg_lock_sleep())); epee::critical_region_t<decltype(x)> critical_region_var1(x)
|
||||
#define CRITICAL_REGION_BEGIN(x) { std::this_thread::sleep_for(std::chrono::milliseconds(epee::debug::g_test_dbg_lock_sleep())); epee::critical_region_t<decltype(x)> critical_region_var(x)
|
||||
#define CRITICAL_REGION_LOCAL1(x) {std::this_thread::sleep_for(std::chrono::milliseconds(epee::debug::g_test_dbg_lock_sleep()));} epee::critical_region_t<decltype(x)> critical_region_var1(x)
|
||||
#define CRITICAL_REGION_BEGIN1(x) { std::this_thread::sleep_for(std::chrono::milliseconds(epee::debug::g_test_dbg_lock_sleep())); epee::critical_region_t<decltype(x)> critical_region_var1(x)
|
||||
|
||||
#define CRITICAL_REGION_END() }
|
||||
|
||||
|
|
|
@ -93,9 +93,9 @@ namespace epee
|
|||
size_t mlocker::page_size = 0;
|
||||
size_t mlocker::num_locked_objects = 0;
|
||||
|
||||
boost::mutex &mlocker::mutex()
|
||||
std::mutex &mlocker::mutex()
|
||||
{
|
||||
static boost::mutex *vmutex = new boost::mutex();
|
||||
static std::mutex *vmutex = new std::mutex();
|
||||
return *vmutex;
|
||||
}
|
||||
std::map<size_t, unsigned int> &mlocker::map()
|
||||
|
|
|
@ -220,9 +220,9 @@ network_time_seconds network_throttle::get_sleep_time_after_tick(size_t packet_s
|
|||
}
|
||||
|
||||
void network_throttle::logger_handle_net(const std::string &filename, double time, size_t size) {
|
||||
static boost::mutex mutex;
|
||||
static std::mutex mutex;
|
||||
|
||||
boost::lock_guard<boost::mutex> lock(mutex);
|
||||
std::lock_guard lock{mutex};
|
||||
{
|
||||
std::fstream file;
|
||||
file.open(filename.c_str(), std::ios::app | std::ios::out );
|
||||
|
|
|
@ -67,9 +67,9 @@ namespace net_utils
|
|||
|
||||
// ================================================================================================
|
||||
// static:
|
||||
boost::mutex network_throttle_manager::m_lock_get_global_throttle_in;
|
||||
boost::mutex network_throttle_manager::m_lock_get_global_throttle_inreq;
|
||||
boost::mutex network_throttle_manager::m_lock_get_global_throttle_out;
|
||||
std::mutex network_throttle_manager::m_lock_get_global_throttle_in;
|
||||
std::mutex network_throttle_manager::m_lock_get_global_throttle_inreq;
|
||||
std::mutex network_throttle_manager::m_lock_get_global_throttle_out;
|
||||
|
||||
// ================================================================================================
|
||||
// methods:
|
||||
|
|
|
@ -2,14 +2,13 @@
|
|||
#include <readline/readline.h>
|
||||
#include <readline/history.h>
|
||||
#include <iostream>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/lock_guard.hpp>
|
||||
#include <mutex>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
static void install_line_handler();
|
||||
static void remove_line_handler();
|
||||
|
||||
static boost::mutex sync_mutex;
|
||||
static std::mutex sync_mutex;
|
||||
static rdln::linestatus line_stat;
|
||||
static char *the_line;
|
||||
|
||||
|
@ -69,7 +68,7 @@ void rdln::readline_buffer::stop()
|
|||
|
||||
rdln::linestatus rdln::readline_buffer::get_line(std::string& line) const
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(sync_mutex);
|
||||
std::lock_guard lock{sync_mutex};
|
||||
line_stat = rdln::partial;
|
||||
if (!m_cout_buf)
|
||||
{
|
||||
|
@ -90,7 +89,7 @@ void rdln::readline_buffer::set_prompt(const std::string& prompt)
|
|||
{
|
||||
if(m_cout_buf == NULL)
|
||||
return;
|
||||
boost::lock_guard<boost::mutex> lock(sync_mutex);
|
||||
std::lock_guard lock{sync_mutex};
|
||||
rl_set_prompt(std::string(m_prompt_length, ' ').c_str());
|
||||
rl_redisplay();
|
||||
rl_set_prompt(prompt.c_str());
|
||||
|
@ -112,7 +111,7 @@ const std::vector<std::string>& rdln::readline_buffer::get_completions()
|
|||
|
||||
int rdln::readline_buffer::sync()
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(sync_mutex);
|
||||
std::lock_guard lock{sync_mutex};
|
||||
#if RL_READLINE_VERSION < 0x0700
|
||||
char lbuf[2] = {0,0};
|
||||
char *line = NULL;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include "net/abstract_tcp_server2.h"
|
||||
|
@ -316,7 +316,7 @@ namespace tests
|
|||
inline bool do_test2_work_with_srv(test_levin_server& srv, int port)
|
||||
{
|
||||
uint64_t i = 0;
|
||||
boost::mutex wait_event;
|
||||
std::mutex wait_event;
|
||||
wait_event.lock();
|
||||
while(true)
|
||||
{
|
||||
|
@ -328,14 +328,11 @@ namespace tests
|
|||
LOG_PRINT_L0("Invoking command 1 to " << port);
|
||||
COMMAND_EXAMPLE_1::request arg{};
|
||||
arg.example_id_data = i;
|
||||
/*vc2010 workaround*/
|
||||
int port_ = port;
|
||||
boost::mutex& wait_event_ = wait_event;
|
||||
int r = srv.invoke_async<COMMAND_EXAMPLE_1::request>(cntxt.m_connection_id, COMMAND_EXAMPLE_1::ID, arg, [port_, &wait_event_](int code, const COMMAND_EXAMPLE_1::request& rsp, const net_utils::connection_context_base& cntxt)
|
||||
int r = srv.invoke_async<COMMAND_EXAMPLE_1::request>(cntxt.m_connection_id, COMMAND_EXAMPLE_1::ID, arg, [&port, &wait_event](int code, const COMMAND_EXAMPLE_1::request& rsp, const net_utils::connection_context_base& cntxt)
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(code > 0, void(), "Failed to invoke");
|
||||
LOG_PRINT_L0("command 1 invoke to " << port_ << " OK.");
|
||||
wait_event_.unlock();
|
||||
LOG_PRINT_L0("command 1 invoke to " << port << " OK.");
|
||||
wait_event.unlock();
|
||||
});
|
||||
});
|
||||
wait_event.lock();
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
#include "blockchain_db/blockchain_db.h"
|
||||
#include "cryptonote_basic/blobdatatype.h" // for type blobdata
|
||||
#include "ringct/rctTypes.h"
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/thread/tss.hpp>
|
||||
|
||||
#include <lmdb.h>
|
||||
|
|
|
@ -31,12 +31,12 @@
|
|||
// check local first (in the event of static or in-source compilation of libunbound)
|
||||
#include "unbound.h"
|
||||
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
#include <stdlib.h>
|
||||
#include "include_base_utils.h"
|
||||
#include "common/threadpool.h"
|
||||
#include "crypto/crypto.h"
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
|
||||
#undef LOKI_DEFAULT_LOG_CATEGORY
|
||||
|
@ -51,7 +51,7 @@ static const char *DEFAULT_DNS_PUBLIC_ADDR[] =
|
|||
"193.58.251.251", // SkyDNS (Russia)
|
||||
};
|
||||
|
||||
static boost::mutex instance_lock;
|
||||
static std::mutex instance_lock;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -380,7 +380,7 @@ std::string DNSResolver::get_dns_format_from_oa_address(const std::string& oa_ad
|
|||
|
||||
DNSResolver& DNSResolver::instance()
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(instance_lock);
|
||||
std::lock_guard lock{instance_lock};
|
||||
|
||||
static DNSResolver staticInstance;
|
||||
return staticInstance;
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace tools
|
|||
bool stopped;
|
||||
bool success;
|
||||
boost::thread thread;
|
||||
boost::mutex mutex;
|
||||
std::mutex mutex;
|
||||
|
||||
download_thread_control(const std::string &path, const std::string &uri, std::function<void(const std::string&, const std::string&, bool)> result_cb, std::function<bool(const std::string&, const std::string&, size_t, ssize_t)> progress_cb):
|
||||
path(path), uri(uri), result_cb(result_cb), progress_cb(progress_cb), stop(false), stopped(false), success(false) {}
|
||||
|
@ -72,7 +72,7 @@ namespace tools
|
|||
|
||||
try
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(control->mutex);
|
||||
std::unique_lock lock{control->mutex};
|
||||
std::ios_base::openmode mode = std::ios_base::out | std::ios_base::binary;
|
||||
uint64_t existing_size = 0;
|
||||
if (epee::file_io_utils::get_file_size(control->path, existing_size) && existing_size > 0)
|
||||
|
@ -146,7 +146,7 @@ namespace tools
|
|||
{
|
||||
try
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(control->mutex);
|
||||
std::lock_guard lock{control->mutex};
|
||||
if (control->stop)
|
||||
return false;
|
||||
f << piece_of_transfer;
|
||||
|
@ -190,7 +190,7 @@ namespace tools
|
|||
client.set_server(u_c.host, std::to_string(port), std::nullopt, ssl);
|
||||
if (!client.connect(std::chrono::seconds(30)))
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(control->mutex);
|
||||
std::lock_guard lock{control->mutex};
|
||||
MERROR("Failed to connect to " << control->uri);
|
||||
control->result_cb(control->path, control->uri, control->success);
|
||||
return;
|
||||
|
@ -206,7 +206,7 @@ namespace tools
|
|||
}
|
||||
if (!client.invoke_get(u_c.uri, std::chrono::seconds(30), "", &info, fields))
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(control->mutex);
|
||||
std::lock_guard lock{control->mutex};
|
||||
MERROR("Failed to connect to " << control->uri);
|
||||
client.disconnect();
|
||||
control->result_cb(control->path, control->uri, control->success);
|
||||
|
@ -214,7 +214,7 @@ namespace tools
|
|||
}
|
||||
if (control->stop)
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(control->mutex);
|
||||
std::lock_guard lock{control->mutex};
|
||||
MDEBUG("Download cancelled");
|
||||
client.disconnect();
|
||||
control->result_cb(control->path, control->uri, control->success);
|
||||
|
@ -222,7 +222,7 @@ namespace tools
|
|||
}
|
||||
if (!info)
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(control->mutex);
|
||||
std::lock_guard lock{control->mutex};
|
||||
MERROR("Failed invoking GET command to " << control->uri << ", no status info returned");
|
||||
client.disconnect();
|
||||
control->result_cb(control->path, control->uri, control->success);
|
||||
|
@ -236,7 +236,7 @@ namespace tools
|
|||
MDEBUG("additional field: " << f.first << ": " << f.second);
|
||||
if (info->m_response_code != 200 && info->m_response_code != 206)
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(control->mutex);
|
||||
std::lock_guard lock{control->mutex};
|
||||
MERROR("Status code " << info->m_response_code);
|
||||
client.disconnect();
|
||||
control->result_cb(control->path, control->uri, control->success);
|
||||
|
@ -255,7 +255,7 @@ namespace tools
|
|||
MERROR("Exception in download thread: " << e.what());
|
||||
// fall through and call result_cb not from the catch block to avoid another exception
|
||||
}
|
||||
boost::lock_guard<boost::mutex> lock(control->mutex);
|
||||
std::lock_guard lock{control->mutex};
|
||||
control->result_cb(control->path, control->uri, control->success);
|
||||
}
|
||||
|
||||
|
@ -277,14 +277,14 @@ namespace tools
|
|||
bool download_finished(const download_async_handle &control)
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(control != 0, false, "NULL async download handle");
|
||||
boost::lock_guard<boost::mutex> lock(control->mutex);
|
||||
std::lock_guard lock{control->mutex};
|
||||
return control->stopped;
|
||||
}
|
||||
|
||||
bool download_error(const download_async_handle &control)
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(control != 0, false, "NULL async download handle");
|
||||
boost::lock_guard<boost::mutex> lock(control->mutex);
|
||||
std::lock_guard lock{control->mutex};
|
||||
return !control->success;
|
||||
}
|
||||
|
||||
|
@ -292,7 +292,7 @@ namespace tools
|
|||
{
|
||||
CHECK_AND_ASSERT_MES(control != 0, false, "NULL async download handle");
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(control->mutex);
|
||||
std::lock_guard lock{control->mutex};
|
||||
if (control->stopped)
|
||||
return true;
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ namespace tools
|
|||
{
|
||||
CHECK_AND_ASSERT_MES(control != 0, false, "NULL async download handle");
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(control->mutex);
|
||||
std::lock_guard lock{control->mutex};
|
||||
if (control->stopped)
|
||||
return true;
|
||||
control->stop = true;
|
||||
|
|
|
@ -47,7 +47,7 @@ threadpool::~threadpool() {
|
|||
void threadpool::destroy() {
|
||||
try
|
||||
{
|
||||
const boost::unique_lock<boost::mutex> lock(mutex);
|
||||
const std::unique_lock lock{mutex};
|
||||
running = false;
|
||||
has_work.notify_all();
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ void threadpool::create(unsigned int max_threads) {
|
|||
|
||||
void threadpool::submit(waiter *obj, std::function<void()> f, bool leaf) {
|
||||
CHECK_AND_ASSERT_THROW_MES(!is_leaf, "A leaf routine is using a thread pool");
|
||||
boost::unique_lock<boost::mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
if (!leaf && ((active == max && !queue.empty()) || depth > 0)) {
|
||||
// if all available threads are already running
|
||||
// and there's work waiting, just run in current thread
|
||||
|
@ -113,7 +113,7 @@ threadpool::waiter::~waiter()
|
|||
{
|
||||
try
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mt);
|
||||
std::unique_lock lock{mt};
|
||||
if (num)
|
||||
MERROR("wait should have been called before waiter dtor - waiting now");
|
||||
}
|
||||
|
@ -131,25 +131,25 @@ threadpool::waiter::~waiter()
|
|||
void threadpool::waiter::wait(threadpool *tpool) {
|
||||
if (tpool)
|
||||
tpool->run(true);
|
||||
boost::unique_lock<boost::mutex> lock(mt);
|
||||
std::unique_lock lock{mt};
|
||||
while(num)
|
||||
cv.wait(lock);
|
||||
}
|
||||
|
||||
void threadpool::waiter::inc() {
|
||||
const boost::unique_lock<boost::mutex> lock(mt);
|
||||
const std::unique_lock lock{mt};
|
||||
num++;
|
||||
}
|
||||
|
||||
void threadpool::waiter::dec() {
|
||||
const boost::unique_lock<boost::mutex> lock(mt);
|
||||
const std::unique_lock lock{mt};
|
||||
num--;
|
||||
if (!num)
|
||||
cv.notify_all();
|
||||
}
|
||||
|
||||
void threadpool::run(bool flush) {
|
||||
boost::unique_lock<boost::mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
while (running) {
|
||||
entry e;
|
||||
while(queue.empty() && running)
|
||||
|
|
|
@ -27,14 +27,14 @@
|
|||
// THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#pragma once
|
||||
|
||||
#include <boost/thread/condition_variable.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <cstddef>
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
|
||||
namespace tools
|
||||
{
|
||||
|
@ -53,8 +53,8 @@ public:
|
|||
// The waiter lets the caller know when all of its
|
||||
// tasks are completed.
|
||||
class waiter {
|
||||
boost::mutex mt;
|
||||
boost::condition_variable cv;
|
||||
std::mutex mt;
|
||||
std::condition_variable cv;
|
||||
int num;
|
||||
public:
|
||||
void inc();
|
||||
|
@ -88,8 +88,8 @@ public:
|
|||
bool leaf;
|
||||
} entry;
|
||||
std::deque<entry> queue;
|
||||
boost::condition_variable has_work;
|
||||
boost::mutex mutex;
|
||||
std::condition_variable has_work;
|
||||
std::mutex mutex;
|
||||
std::vector<boost::thread> threads;
|
||||
unsigned int active;
|
||||
unsigned int max;
|
||||
|
|
|
@ -578,24 +578,24 @@ namespace tools
|
|||
|
||||
namespace
|
||||
{
|
||||
boost::mutex max_concurrency_lock;
|
||||
unsigned max_concurrency = boost::thread::hardware_concurrency();
|
||||
std::mutex max_concurrency_lock;
|
||||
unsigned max_concurrency = std::thread::hardware_concurrency();
|
||||
}
|
||||
|
||||
void set_max_concurrency(unsigned n)
|
||||
{
|
||||
if (n < 1)
|
||||
n = boost::thread::hardware_concurrency();
|
||||
unsigned hwc = boost::thread::hardware_concurrency();
|
||||
n = std::thread::hardware_concurrency();
|
||||
unsigned hwc = std::thread::hardware_concurrency();
|
||||
if (n > hwc)
|
||||
n = hwc;
|
||||
boost::lock_guard<boost::mutex> lock(max_concurrency_lock);
|
||||
std::lock_guard lock{max_concurrency_lock};
|
||||
max_concurrency = n;
|
||||
}
|
||||
|
||||
unsigned get_max_concurrency()
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(max_concurrency_lock);
|
||||
std::lock_guard lock{max_concurrency_lock};
|
||||
return max_concurrency;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <boost/thread/locks.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/endian/conversion.hpp>
|
||||
#include <optional>
|
||||
#include <system_error>
|
||||
|
@ -205,8 +203,8 @@ namespace tools
|
|||
/*! \brief calles m_handler */
|
||||
static void handle_signal(int type)
|
||||
{
|
||||
static boost::mutex m_mutex;
|
||||
boost::unique_lock<boost::mutex> lock(m_mutex);
|
||||
static std::mutex m_mutex;
|
||||
std::unique_lock lock{m_mutex};
|
||||
m_handler(type);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,14 +28,13 @@
|
|||
//
|
||||
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
||||
|
||||
#include <mutex>
|
||||
#include <unistd.h>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/lock_guard.hpp>
|
||||
|
||||
#include "common/varint.h"
|
||||
#include "warnings.h"
|
||||
|
@ -87,21 +86,21 @@ namespace crypto {
|
|||
return &reinterpret_cast<const unsigned char &>(scalar);
|
||||
}
|
||||
|
||||
boost::mutex &get_random_lock()
|
||||
static auto get_random_lock()
|
||||
{
|
||||
static boost::mutex random_lock;
|
||||
return random_lock;
|
||||
static std::mutex random_mutex;
|
||||
return std::lock_guard{random_mutex};
|
||||
}
|
||||
|
||||
void generate_random_bytes_thread_safe(size_t N, uint8_t *bytes)
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(get_random_lock());
|
||||
auto lock = get_random_lock();
|
||||
generate_random_bytes_not_thread_safe(N, bytes);
|
||||
}
|
||||
|
||||
void add_extra_entropy_thread_safe(const void *ptr, size_t bytes)
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(get_random_lock());
|
||||
auto lock = get_random_lock();
|
||||
add_extra_entropy_not_thread_safe(ptr, bytes);
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include <boost/program_options.hpp>
|
||||
#include <boost/logic/tribool_fwd.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <atomic>
|
||||
#include "cryptonote_basic/blobdatatype.h"
|
||||
#include "cryptonote_basic/cryptonote_basic.h"
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
#include <boost/multi_index/global_fun.hpp>
|
||||
#include <boost/multi_index/hashed_index.hpp>
|
||||
#include <boost/multi_index/member.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
#include <unordered_map>
|
||||
|
@ -1011,12 +1012,6 @@ namespace cryptonote
|
|||
void unlock() const { m_blockchain_lock.unlock(); }
|
||||
bool try_lock() const { return m_blockchain_lock.try_lock(); }
|
||||
|
||||
/* These are needed as a workaround for boost::lock not considering the type lockable if const
|
||||
* versions are defined. When we switch to std::lock these can go. */
|
||||
void lock() { m_blockchain_lock.lock(); }
|
||||
void unlock() { m_blockchain_lock.unlock(); }
|
||||
bool try_lock() { return m_blockchain_lock.try_lock(); }
|
||||
|
||||
void cancel();
|
||||
|
||||
/**
|
||||
|
@ -1084,7 +1079,7 @@ namespace cryptonote
|
|||
service_nodes::service_node_list& m_service_node_list;
|
||||
lns::name_system_db m_lns_db;
|
||||
|
||||
mutable boost::recursive_mutex m_blockchain_lock; // TODO: add here reader/writer lock
|
||||
mutable std::recursive_mutex m_blockchain_lock; // TODO: add here reader/writer lock
|
||||
|
||||
// main chain
|
||||
size_t m_current_block_cumul_weight_limit;
|
||||
|
|
|
@ -354,7 +354,7 @@ namespace cryptonote
|
|||
|
||||
tools::download_async_handle handle;
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(m_update_mutex);
|
||||
std::lock_guard lock{m_update_mutex};
|
||||
handle = m_update_download;
|
||||
m_update_download = 0;
|
||||
}
|
||||
|
@ -1193,7 +1193,7 @@ namespace cryptonote
|
|||
}
|
||||
//std::cout << "!"<< tx.vin.size() << std::endl;
|
||||
|
||||
std::lock_guard<boost::mutex> lock(bad_semantics_txes_lock);
|
||||
std::lock_guard lock{bad_semantics_txes_lock};
|
||||
for (int idx = 0; idx < 2; ++idx)
|
||||
{
|
||||
if (bad_semantics_txes[idx].find(tx_info.tx_hash) != bad_semantics_txes[idx].end())
|
||||
|
@ -2335,7 +2335,7 @@ namespace cryptonote
|
|||
boost::filesystem::path path(epee::string_tools::get_current_module_folder());
|
||||
path /= filename;
|
||||
|
||||
boost::unique_lock<boost::mutex> lock(m_update_mutex);
|
||||
std::unique_lock lock{m_update_mutex};
|
||||
|
||||
if (m_update_download != 0)
|
||||
{
|
||||
|
@ -2376,7 +2376,7 @@ namespace cryptonote
|
|||
MCERROR("updates", "Failed to download " << uri);
|
||||
good = false;
|
||||
}
|
||||
boost::unique_lock<boost::mutex> lock(m_update_mutex);
|
||||
std::unique_lock lock{m_update_mutex};
|
||||
m_update_download = 0;
|
||||
if (success && !remove)
|
||||
{
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <ctime>
|
||||
#include <future>
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
|
||||
#include <boost/program_options/options_description.hpp>
|
||||
#include <boost/program_options/variables_map.hpp>
|
||||
|
@ -171,7 +172,7 @@ namespace cryptonote
|
|||
};
|
||||
|
||||
/// Returns an RAII unique lock holding the incoming tx mutex.
|
||||
auto incoming_tx_lock() { return std::unique_lock<boost::recursive_mutex>{m_incoming_tx_lock}; }
|
||||
auto incoming_tx_lock() { return std::unique_lock{m_incoming_tx_lock}; }
|
||||
|
||||
/**
|
||||
* @brief parses a list of incoming transactions
|
||||
|
@ -1171,7 +1172,7 @@ namespace cryptonote
|
|||
i_cryptonote_protocol* m_pprotocol; //!< cryptonote protocol instance
|
||||
cryptonote_protocol_stub m_protocol_stub; //!< cryptonote protocol stub instance
|
||||
|
||||
boost::recursive_mutex m_incoming_tx_lock; //!< incoming transaction lock
|
||||
std::recursive_mutex m_incoming_tx_lock; //!< incoming transaction lock
|
||||
|
||||
//m_miner and m_miner_addres are probably temporary here
|
||||
miner m_miner; //!< miner instance
|
||||
|
@ -1228,7 +1229,7 @@ namespace cryptonote
|
|||
time_t start_time;
|
||||
|
||||
std::unordered_set<crypto::hash> bad_semantics_txes[2];
|
||||
boost::mutex bad_semantics_txes_lock;
|
||||
std::mutex bad_semantics_txes_lock;
|
||||
|
||||
enum {
|
||||
UPDATES_DISABLED,
|
||||
|
@ -1239,7 +1240,7 @@ namespace cryptonote
|
|||
|
||||
tools::download_async_handle m_update_download;
|
||||
size_t m_last_update_length;
|
||||
boost::mutex m_update_mutex;
|
||||
std::mutex m_update_mutex;
|
||||
|
||||
bool m_offline;
|
||||
bool m_pad_transactions;
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
#include <boost/variant.hpp>
|
||||
#include <mutex>
|
||||
#include <shared_mutex>
|
||||
#include <boost/thread/shared_mutex.hpp>
|
||||
#include <string_view>
|
||||
#include "serialization/serialization.h"
|
||||
#include "cryptonote_basic/cryptonote_basic_impl.h"
|
||||
|
@ -321,7 +320,7 @@ namespace service_nodes
|
|||
void init() override;
|
||||
bool validate_miner_tx(const crypto::hash& prev_id, const cryptonote::transaction& miner_tx, uint64_t height, int hard_fork_version, cryptonote::block_reward_parts const &base_reward) const override;
|
||||
bool alt_block_added(const cryptonote::block& block, const std::vector<cryptonote::transaction>& txs, cryptonote::checkpoint_t const *checkpoint) override;
|
||||
block_winner get_block_winner() const { std::lock_guard<boost::recursive_mutex> lock(m_sn_mutex); return m_state.get_block_winner(); }
|
||||
block_winner get_block_winner() const { std::lock_guard lock{m_sn_mutex}; return m_state.get_block_winner(); }
|
||||
bool is_service_node(const crypto::public_key& pubkey, bool require_active = true) const;
|
||||
bool is_key_image_locked(crypto::key_image const &check_image, uint64_t *unlock_height = nullptr, service_node_info::contribution_t *the_locked_contribution = nullptr) const;
|
||||
uint64_t height() const { return m_state.height; }
|
||||
|
@ -345,7 +344,7 @@ namespace service_nodes
|
|||
/// at all for the given pubkey then Func will not be called.
|
||||
template <typename Func>
|
||||
void access_proof(const crypto::public_key &pubkey, Func f) const {
|
||||
std::unique_lock<boost::recursive_mutex> lock;
|
||||
std::unique_lock lock{m_sn_mutex};
|
||||
auto it = proofs.find(pubkey);
|
||||
if (it != proofs.end())
|
||||
f(it->second);
|
||||
|
@ -370,7 +369,7 @@ namespace service_nodes
|
|||
template <typename It, typename Func>
|
||||
void for_each_service_node_info_and_proof(It begin, It end, Func f) const {
|
||||
static const proof_info empty_proof{};
|
||||
std::lock_guard<boost::recursive_mutex> lock(m_sn_mutex);
|
||||
std::lock_guard lock{m_sn_mutex};
|
||||
for (auto sni_end = m_state.service_nodes_infos.end(); begin != end; ++begin) {
|
||||
auto it = m_state.service_nodes_infos.find(*begin);
|
||||
if (it != sni_end) {
|
||||
|
@ -383,7 +382,7 @@ namespace service_nodes
|
|||
/// Copies x25519 pubkeys (as strings) of all currently active SNs into the given output iterator
|
||||
template <typename OutputIt>
|
||||
void copy_active_x25519_pubkeys(OutputIt out) const {
|
||||
std::lock_guard<boost::recursive_mutex> lock(m_sn_mutex);
|
||||
std::lock_guard lock{m_sn_mutex};
|
||||
for (const auto& pk_info : m_state.service_nodes_infos) {
|
||||
if (!pk_info.second->is_active())
|
||||
continue;
|
||||
|
@ -530,11 +529,11 @@ namespace service_nodes
|
|||
void reset(bool delete_db_entry = false);
|
||||
bool load(uint64_t current_height);
|
||||
|
||||
mutable boost::recursive_mutex m_sn_mutex;
|
||||
cryptonote::Blockchain& m_blockchain;
|
||||
const service_node_keys *m_service_node_keys;
|
||||
uint64_t m_store_quorum_history = 0;
|
||||
mutable boost::shared_mutex m_x25519_map_mutex;
|
||||
mutable std::recursive_mutex m_sn_mutex;
|
||||
cryptonote::Blockchain& m_blockchain;
|
||||
const service_node_keys *m_service_node_keys;
|
||||
uint64_t m_store_quorum_history = 0;
|
||||
mutable std::shared_mutex m_x25519_map_mutex;
|
||||
|
||||
/// Maps x25519 pubkeys to registration pubkeys + last block seen value (used for expiry)
|
||||
std::unordered_map<crypto::x25519_public_key, std::pair<crypto::public_key, time_t>> x25519_to_pub;
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include "service_node_rules.h"
|
||||
#include <iostream>
|
||||
#include <shared_mutex>
|
||||
#include <boost/thread/shared_mutex.hpp>
|
||||
|
||||
namespace service_nodes {
|
||||
class service_node_list;
|
||||
|
@ -87,12 +86,12 @@ public:
|
|||
/// Obtains a unique lock on this blink tx; required for any signature-mutating method unless
|
||||
/// otherwise noted
|
||||
template <typename... Args>
|
||||
auto unique_lock(Args &&...args) { return std::unique_lock<boost::shared_mutex>{mutex_, std::forward<Args>(args)...}; }
|
||||
auto unique_lock(Args &&...args) { return std::unique_lock{mutex_, std::forward<Args>(args)...}; }
|
||||
|
||||
/// Obtains a shared lock on this blink tx; required for any signature-dependent method unless
|
||||
/// otherwise noted
|
||||
template <typename... Args>
|
||||
auto shared_lock(Args &&...args) { return std::shared_lock<boost::shared_mutex>{mutex_, std::forward<Args>(args)...}; }
|
||||
auto shared_lock(Args &&...args) { return std::shared_lock{mutex_, std::forward<Args>(args)...}; }
|
||||
|
||||
/**
|
||||
* Sets the maximum number of signatures for the given subquorum type, if the given size is less
|
||||
|
@ -195,7 +194,7 @@ private:
|
|||
}
|
||||
|
||||
std::array<std::array<quorum_signature, service_nodes::BLINK_SUBQUORUM_SIZE>, tools::enum_count<subquorum>> signatures_;
|
||||
boost::shared_mutex mutex_;
|
||||
std::shared_mutex mutex_;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -644,7 +644,7 @@ namespace cryptonote
|
|||
{
|
||||
auto bl_lock = blink_shared_lock(std::defer_lock);
|
||||
std::unique_lock bc_lock{m_blockchain, std::defer_lock};
|
||||
boost::lock(bl_lock, bc_lock);
|
||||
std::lock(bl_lock, bc_lock);
|
||||
|
||||
// Since this is a signed blink tx, we want to see if we can eject any existing mempool
|
||||
// txes to make room.
|
||||
|
@ -765,9 +765,7 @@ namespace cryptonote
|
|||
auto blink_lock = blink_shared_lock(std::defer_lock);
|
||||
std::unique_lock tx_lock{*this, std::defer_lock};
|
||||
std::unique_lock bc_lock{m_blockchain, std::defer_lock};
|
||||
// Breaks on macOS's broken SDK version 10.11 that we currently use:
|
||||
//std::lock(blink_lock, tx_lock, bc_lock);
|
||||
boost::lock(blink_lock, tx_lock, bc_lock);
|
||||
std::lock(blink_lock, tx_lock, bc_lock);
|
||||
LockedTXN lock(m_blockchain);
|
||||
bool changed = false;
|
||||
|
||||
|
@ -1264,7 +1262,7 @@ namespace cryptonote
|
|||
std::unique_lock tx_lock{m_transactions_lock, std::defer_lock};
|
||||
std::unique_lock bc_lock{m_blockchain, std::defer_lock};
|
||||
auto blink_lock = blink_shared_lock(std::defer_lock);
|
||||
boost::lock(tx_lock, bc_lock, blink_lock);
|
||||
std::lock(tx_lock, bc_lock, blink_lock);
|
||||
|
||||
tx_infos.reserve(m_blockchain.get_txpool_tx_count());
|
||||
key_image_infos.reserve(m_blockchain.get_txpool_tx_count());
|
||||
|
|
|
@ -346,23 +346,17 @@ namespace cryptonote
|
|||
*/
|
||||
bool try_lock() const { return m_transactions_lock.try_lock(); }
|
||||
|
||||
/* These are needed as a workaround for boost::lock not considering the type lockable if const
|
||||
* versions are defined. When we switch to std::lock these can go. */
|
||||
void lock() { m_transactions_lock.lock(); }
|
||||
void unlock() { m_transactions_lock.unlock(); }
|
||||
bool try_lock() { return m_transactions_lock.try_lock(); }
|
||||
|
||||
/**
|
||||
* @brief obtains a unique lock on the approved blink tx pool
|
||||
*/
|
||||
template <typename... Args>
|
||||
auto blink_unique_lock(Args &&...args) const { return std::unique_lock<boost::shared_mutex>{m_blinks_mutex, std::forward<Args>(args)...}; }
|
||||
auto blink_unique_lock(Args &&...args) const { return std::unique_lock{m_blinks_mutex, std::forward<Args>(args)...}; }
|
||||
|
||||
/**
|
||||
* @brief obtains a shared lock on the approved blink tx pool
|
||||
*/
|
||||
template <typename... Args>
|
||||
auto blink_shared_lock(Args &&...args) const { return std::shared_lock<boost::shared_mutex>{m_blinks_mutex, std::forward<Args>(args)...}; }
|
||||
auto blink_shared_lock(Args &&...args) const { return std::shared_lock{m_blinks_mutex, std::forward<Args>(args)...}; }
|
||||
|
||||
|
||||
// load/store operations
|
||||
|
@ -734,7 +728,7 @@ namespace cryptonote
|
|||
*/
|
||||
typedef std::unordered_map<crypto::key_image, std::unordered_set<crypto::hash> > key_images_container;
|
||||
|
||||
mutable boost::recursive_mutex m_transactions_lock; //!< mutex for the pool
|
||||
mutable std::recursive_mutex m_transactions_lock; //!< mutex for the pool
|
||||
|
||||
//! container for spent key images from the transactions in the pool
|
||||
key_images_container m_spent_key_images;
|
||||
|
@ -779,7 +773,7 @@ namespace cryptonote
|
|||
|
||||
std::unordered_map<crypto::hash, transaction> m_parsed_tx_cache;
|
||||
|
||||
mutable boost::shared_mutex m_blinks_mutex;
|
||||
mutable std::shared_mutex m_blinks_mutex;
|
||||
|
||||
// Contains blink metadata for approved blink transactions. { txhash => blink_tx, ... }.
|
||||
mutable std::unordered_map<crypto::hash, std::shared_ptr<cryptonote::blink_tx>> m_blinks;
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace cryptonote
|
|||
|
||||
void block_queue::add_blocks(uint64_t height, std::vector<cryptonote::block_complete_entry> bcel, const boost::uuids::uuid &connection_id, float rate, size_t size)
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
std::vector<crypto::hash> hashes;
|
||||
bool has_hashes = remove_span(height, &hashes);
|
||||
blocks.emplace(height, std::move(bcel), connection_id, rate, size);
|
||||
|
@ -73,13 +73,13 @@ void block_queue::add_blocks(uint64_t height, std::vector<cryptonote::block_comp
|
|||
void block_queue::add_blocks(uint64_t height, uint64_t nblocks, const boost::uuids::uuid &connection_id, boost::posix_time::ptime time)
|
||||
{
|
||||
CHECK_AND_ASSERT_THROW_MES(nblocks > 0, "Empty span");
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
blocks.insert(span(height, nblocks, connection_id, time));
|
||||
}
|
||||
|
||||
void block_queue::flush_spans(const boost::uuids::uuid &connection_id, bool all)
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
block_map::iterator i = blocks.begin();
|
||||
while (i != blocks.end())
|
||||
{
|
||||
|
@ -104,7 +104,7 @@ void block_queue::erase_block(block_map::iterator j)
|
|||
|
||||
void block_queue::flush_stale_spans(const std::set<boost::uuids::uuid> &live_connections)
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
block_map::iterator i = blocks.begin();
|
||||
while (i != blocks.end())
|
||||
{
|
||||
|
@ -118,7 +118,7 @@ void block_queue::flush_stale_spans(const std::set<boost::uuids::uuid> &live_con
|
|||
|
||||
bool block_queue::remove_span(uint64_t start_block_height, std::vector<crypto::hash> *hashes)
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
for (block_map::iterator i = blocks.begin(); i != blocks.end(); ++i)
|
||||
{
|
||||
if (i->start_block_height == start_block_height)
|
||||
|
@ -134,7 +134,7 @@ bool block_queue::remove_span(uint64_t start_block_height, std::vector<crypto::h
|
|||
|
||||
void block_queue::remove_spans(const boost::uuids::uuid &connection_id, uint64_t start_block_height)
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
for (block_map::iterator i = blocks.begin(); i != blocks.end(); )
|
||||
{
|
||||
block_map::iterator j = i++;
|
||||
|
@ -147,7 +147,7 @@ void block_queue::remove_spans(const boost::uuids::uuid &connection_id, uint64_t
|
|||
|
||||
uint64_t block_queue::get_max_block_height() const
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
uint64_t height = 0;
|
||||
for (const auto &span: blocks)
|
||||
{
|
||||
|
@ -160,7 +160,7 @@ uint64_t block_queue::get_max_block_height() const
|
|||
|
||||
uint64_t block_queue::get_next_needed_height(uint64_t blockchain_height) const
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
if (blocks.empty())
|
||||
return blockchain_height;
|
||||
uint64_t last_needed_height = blockchain_height;
|
||||
|
@ -179,7 +179,7 @@ uint64_t block_queue::get_next_needed_height(uint64_t blockchain_height) const
|
|||
|
||||
void block_queue::print() const
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
MDEBUG("Block queue has " << blocks.size() << " spans");
|
||||
for (const auto &span: blocks)
|
||||
MDEBUG(" " << span.start_block_height << " - " << (span.start_block_height+span.nblocks-1) << " (" << span.nblocks << ") - " << (span.blocks.empty() ? "scheduled" : "filled ") << " " << span.connection_id << " (" << ((unsigned)(span.rate*10/1024.f))/10.f << " kB/s)");
|
||||
|
@ -187,7 +187,7 @@ void block_queue::print() const
|
|||
|
||||
std::string block_queue::get_overview(uint64_t blockchain_height) const
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
if (blocks.empty())
|
||||
return "[]";
|
||||
block_map::const_iterator i = blocks.begin();
|
||||
|
@ -219,19 +219,19 @@ inline bool block_queue::requested_internal(const crypto::hash &hash) const
|
|||
|
||||
bool block_queue::requested(const crypto::hash &hash) const
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
return requested_internal(hash);
|
||||
}
|
||||
|
||||
bool block_queue::have(const crypto::hash &hash) const
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
return have_blocks.find(hash) != have_blocks.end();
|
||||
}
|
||||
|
||||
std::pair<uint64_t, uint64_t> block_queue::reserve_span(uint64_t first_block_height, uint64_t last_block_height, uint64_t max_blocks, const boost::uuids::uuid &connection_id, uint32_t pruning_seed, uint64_t blockchain_height, const std::vector<crypto::hash> &block_hashes, boost::posix_time::ptime time)
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
|
||||
MDEBUG("reserve_span: first_block_height " << first_block_height << ", last_block_height " << last_block_height
|
||||
<< ", max " << max_blocks << ", seed " << epee::string_tools::to_string_hex(pruning_seed) << ", blockchain_height " <<
|
||||
|
@ -302,7 +302,7 @@ std::pair<uint64_t, uint64_t> block_queue::reserve_span(uint64_t first_block_hei
|
|||
|
||||
std::pair<uint64_t, uint64_t> block_queue::get_next_span_if_scheduled(std::vector<crypto::hash> &hashes, boost::uuids::uuid &connection_id, boost::posix_time::ptime &time) const
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
if (blocks.empty())
|
||||
return std::make_pair(0, 0);
|
||||
block_map::const_iterator i = blocks.begin();
|
||||
|
@ -318,7 +318,7 @@ std::pair<uint64_t, uint64_t> block_queue::get_next_span_if_scheduled(std::vecto
|
|||
|
||||
void block_queue::reset_next_span_time(boost::posix_time::ptime t)
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
CHECK_AND_ASSERT_THROW_MES(!blocks.empty(), "No next span to reset time");
|
||||
block_map::iterator i = blocks.begin();
|
||||
CHECK_AND_ASSERT_THROW_MES(i != blocks.end(), "No next span to reset time");
|
||||
|
@ -328,7 +328,7 @@ void block_queue::reset_next_span_time(boost::posix_time::ptime t)
|
|||
|
||||
void block_queue::set_span_hashes(uint64_t start_height, const boost::uuids::uuid &connection_id, std::vector<crypto::hash> hashes)
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
for (block_map::iterator i = blocks.begin(); i != blocks.end(); ++i)
|
||||
{
|
||||
if (i->start_block_height == start_height && i->connection_id == connection_id)
|
||||
|
@ -346,7 +346,7 @@ void block_queue::set_span_hashes(uint64_t start_height, const boost::uuids::uui
|
|||
|
||||
bool block_queue::get_next_span(uint64_t &height, std::vector<cryptonote::block_complete_entry> &bcel, boost::uuids::uuid &connection_id, bool filled) const
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
if (blocks.empty())
|
||||
return false;
|
||||
block_map::const_iterator i = blocks.begin();
|
||||
|
@ -365,7 +365,7 @@ bool block_queue::get_next_span(uint64_t &height, std::vector<cryptonote::block_
|
|||
|
||||
bool block_queue::has_next_span(const boost::uuids::uuid &connection_id, bool &filled, boost::posix_time::ptime &time) const
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
if (blocks.empty())
|
||||
return false;
|
||||
block_map::const_iterator i = blocks.begin();
|
||||
|
@ -380,7 +380,7 @@ bool block_queue::has_next_span(const boost::uuids::uuid &connection_id, bool &f
|
|||
|
||||
bool block_queue::has_next_span(uint64_t height, bool &filled, boost::posix_time::ptime &time, boost::uuids::uuid &connection_id) const
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
if (blocks.empty())
|
||||
return false;
|
||||
block_map::const_iterator i = blocks.begin();
|
||||
|
@ -396,7 +396,7 @@ bool block_queue::has_next_span(uint64_t height, bool &filled, boost::posix_time
|
|||
|
||||
size_t block_queue::get_data_size() const
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
size_t size = 0;
|
||||
for (const auto &span: blocks)
|
||||
size += span.size;
|
||||
|
@ -405,7 +405,7 @@ size_t block_queue::get_data_size() const
|
|||
|
||||
size_t block_queue::get_num_filled_spans_prefix() const
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
|
||||
if (blocks.empty())
|
||||
return 0;
|
||||
|
@ -421,7 +421,7 @@ size_t block_queue::get_num_filled_spans_prefix() const
|
|||
|
||||
size_t block_queue::get_num_filled_spans() const
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
size_t size = 0;
|
||||
for (const auto &span: blocks)
|
||||
if (!span.blocks.empty())
|
||||
|
@ -431,7 +431,7 @@ size_t block_queue::get_num_filled_spans() const
|
|||
|
||||
crypto::hash block_queue::get_last_known_hash(const boost::uuids::uuid &connection_id) const
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
crypto::hash hash = crypto::null_hash;
|
||||
uint64_t highest_height = 0;
|
||||
for (const auto &span: blocks)
|
||||
|
@ -460,7 +460,7 @@ bool block_queue::has_spans(const boost::uuids::uuid &connection_id) const
|
|||
|
||||
float block_queue::get_speed(const boost::uuids::uuid &connection_id) const
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
std::unordered_map<boost::uuids::uuid, float> speeds;
|
||||
for (const auto &span: blocks)
|
||||
{
|
||||
|
@ -496,7 +496,7 @@ float block_queue::get_speed(const boost::uuids::uuid &connection_id) const
|
|||
|
||||
float block_queue::get_download_rate(const boost::uuids::uuid &connection_id) const
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
float conn_rate = -1.f;
|
||||
for (const auto &span: blocks)
|
||||
{
|
||||
|
@ -521,7 +521,7 @@ float block_queue::get_download_rate(const boost::uuids::uuid &connection_id) co
|
|||
|
||||
bool block_queue::foreach(std::function<bool(const span&)> f) const
|
||||
{
|
||||
boost::unique_lock<boost::recursive_mutex> lock(mutex);
|
||||
std::unique_lock lock{mutex};
|
||||
block_map::const_iterator i = blocks.begin();
|
||||
while (i != blocks.end())
|
||||
if (!f(*i++))
|
||||
|
|
|
@ -35,8 +35,9 @@
|
|||
#include <vector>
|
||||
#include <set>
|
||||
#include <unordered_set>
|
||||
#include <boost/thread/recursive_mutex.hpp>
|
||||
#include <mutex>
|
||||
#include <boost/uuid/uuid.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time_types.hpp>
|
||||
|
||||
#undef LOKI_DEFAULT_LOG_CATEGORY
|
||||
#define LOKI_DEFAULT_LOG_CATEGORY "cn.block_queue"
|
||||
|
@ -104,7 +105,7 @@ namespace cryptonote
|
|||
|
||||
private:
|
||||
block_map blocks;
|
||||
mutable boost::recursive_mutex mutex;
|
||||
mutable std::recursive_mutex mutex;
|
||||
std::unordered_set<crypto::hash> requested_hashes;
|
||||
std::unordered_set<crypto::hash> have_blocks;
|
||||
};
|
||||
|
|
|
@ -174,7 +174,7 @@ namespace cryptonote
|
|||
std::atomic<bool> m_synchronized;
|
||||
std::atomic<bool> m_stopping;
|
||||
std::atomic<bool> m_no_sync;
|
||||
boost::mutex m_sync_lock;
|
||||
std::mutex m_sync_lock;
|
||||
block_queue m_block_queue;
|
||||
tools::periodic_task m_idle_peer_kicker{30s};
|
||||
tools::periodic_task m_standby_checker{100ms};
|
||||
|
@ -194,7 +194,7 @@ namespace cryptonote
|
|||
uint64_t get_estimated_remaining_sync_seconds(uint64_t current_blockchain_height, uint64_t target_blockchain_height);
|
||||
std::string get_periodic_sync_estimate(uint64_t current_blockchain_height, uint64_t target_blockchain_height);
|
||||
|
||||
boost::mutex m_buffer_mutex;
|
||||
std::mutex m_buffer_mutex;
|
||||
boost::circular_buffer<size_t> m_avg_buffer = boost::circular_buffer<size_t>(10);
|
||||
|
||||
template<class t_parameter>
|
||||
|
|
|
@ -74,7 +74,7 @@ struct QnetState {
|
|||
// Track submitted blink txes here; unlike the blinks stored in the mempool we store these ones
|
||||
// more liberally to track submitted blinks, even if unsigned/unacceptable, while the mempool
|
||||
// only stores approved blinks.
|
||||
boost::shared_mutex mutex;
|
||||
std::shared_mutex mutex;
|
||||
|
||||
struct blink_metadata {
|
||||
std::shared_ptr<blink_tx> btxptr;
|
||||
|
@ -1139,7 +1139,7 @@ struct blink_result_data {
|
|||
std::atomic<int> nostart_count{0};
|
||||
};
|
||||
std::unordered_map<uint64_t, blink_result_data> pending_blink_results;
|
||||
boost::shared_mutex pending_blink_result_mutex;
|
||||
std::shared_mutex pending_blink_result_mutex;
|
||||
|
||||
// Sanity check against runaway active pending blink submissions
|
||||
constexpr size_t MAX_ACTIVE_PROMISES = 1000;
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace windows {
|
|||
private:
|
||||
SERVICE_STATUS_HANDLE m_status_handle{nullptr};
|
||||
SERVICE_STATUS m_status{};
|
||||
boost::mutex m_lock{};
|
||||
std::mutex m_lock;
|
||||
std::string m_name;
|
||||
Application app;
|
||||
|
||||
|
|
|
@ -35,8 +35,6 @@
|
|||
#include "device.hpp"
|
||||
#include "log.hpp"
|
||||
#include "device_io_hid.hpp"
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/recursive_mutex.hpp>
|
||||
|
||||
namespace hw {
|
||||
|
||||
|
@ -155,8 +153,8 @@ namespace hw {
|
|||
class device_ledger : public hw::device {
|
||||
private:
|
||||
// Locker for concurrent access
|
||||
mutable boost::recursive_mutex device_locker;
|
||||
mutable boost::mutex command_locker;
|
||||
mutable std::recursive_mutex device_locker;
|
||||
mutable std::mutex command_locker;
|
||||
|
||||
//IO
|
||||
hw::io::device_io_hid hw_device;
|
||||
|
|
|
@ -37,8 +37,7 @@
|
|||
#include <cstddef>
|
||||
#include <string>
|
||||
#include <boost/scope_exit.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/recursive_mutex.hpp>
|
||||
#include <mutex>
|
||||
|
||||
#include "device/device_default.hpp"
|
||||
#include "device/device_cold.hpp"
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
#include <atomic>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
#include <boost/program_options/options_description.hpp>
|
||||
#include <boost/program_options/variables_map.hpp>
|
||||
#include <boost/uuid/uuid.hpp>
|
||||
|
@ -477,7 +476,7 @@ namespace nodetool
|
|||
epee::critical_section m_host_fails_score_lock;
|
||||
std::map<std::string, uint64_t> m_host_fails_score;
|
||||
|
||||
boost::mutex m_used_stripe_peers_mutex;
|
||||
std::mutex m_used_stripe_peers_mutex;
|
||||
std::array<std::list<epee::net_utils::network_address>, 1 << CRYPTONOTE_PRUNING_LOG_STRIPES> m_used_stripe_peers;
|
||||
|
||||
boost::uuids::uuid m_network_id;
|
||||
|
|
|
@ -30,8 +30,6 @@
|
|||
// Paper references are to https://eprint.iacr.org/2017/1066 (revision 1 July 2018)
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/lock_guard.hpp>
|
||||
#include "misc_log_ex.h"
|
||||
#include "span.h"
|
||||
#include "common/perf_timer.h"
|
||||
|
@ -80,7 +78,7 @@ static const rct::key MINUS_INV_EIGHT = { { 0x74, 0xa4, 0x19, 0x7a, 0xf0, 0x7d,
|
|||
static const rct::keyV oneN = vector_dup(rct::identity(), maxN);
|
||||
static const rct::keyV twoN = vector_powers(TWO, maxN);
|
||||
static const rct::key ip12 = inner_product(oneN, twoN);
|
||||
static boost::mutex init_mutex;
|
||||
static std::mutex init_mutex;
|
||||
|
||||
static inline rct::key multiexp(const std::vector<MultiexpData> &data, size_t HiGi_size)
|
||||
{
|
||||
|
@ -112,7 +110,7 @@ static rct::key get_exponent(const rct::key &base, size_t idx)
|
|||
|
||||
static void init_exponents()
|
||||
{
|
||||
boost::lock_guard<boost::mutex> lock(init_mutex);
|
||||
std::lock_guard lock{init_mutex};
|
||||
|
||||
static bool init_done = false;
|
||||
if (init_done)
|
||||
|
|
|
@ -262,7 +262,7 @@ namespace cryptonote { namespace rpc {
|
|||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool core_rpc_server::set_bootstrap_daemon(const std::string &address, const std::optional<epee::net_utils::http::login> &credentials)
|
||||
{
|
||||
boost::unique_lock<boost::shared_mutex> lock(m_bootstrap_daemon_mutex);
|
||||
std::unique_lock lock{m_bootstrap_daemon_mutex};
|
||||
|
||||
if (address.empty())
|
||||
{
|
||||
|
@ -334,7 +334,7 @@ namespace cryptonote { namespace rpc {
|
|||
if (use_bootstrap_daemon_if_necessary<GET_INFO>(req, res))
|
||||
{
|
||||
{
|
||||
boost::shared_lock<boost::shared_mutex> lock(m_bootstrap_daemon_mutex);
|
||||
std::shared_lock lock{m_bootstrap_daemon_mutex};
|
||||
if (m_bootstrap_daemon.get() != nullptr)
|
||||
{
|
||||
res.bootstrap_daemon_address = m_bootstrap_daemon->address();
|
||||
|
@ -410,7 +410,7 @@ namespace cryptonote { namespace rpc {
|
|||
}
|
||||
else
|
||||
{
|
||||
boost::shared_lock<boost::shared_mutex> lock(m_bootstrap_daemon_mutex);
|
||||
std::shared_lock lock{m_bootstrap_daemon_mutex};
|
||||
if (m_bootstrap_daemon.get() != nullptr)
|
||||
{
|
||||
res.bootstrap_daemon_address = m_bootstrap_daemon->address();
|
||||
|
@ -1080,7 +1080,7 @@ namespace cryptonote { namespace rpc {
|
|||
return res;
|
||||
}
|
||||
|
||||
unsigned int concurrency_count = boost::thread::hardware_concurrency() * 4;
|
||||
unsigned int concurrency_count = std::thread::hardware_concurrency() * 4;
|
||||
|
||||
// if we couldn't detect threads, set it to a ridiculously high number
|
||||
if(concurrency_count == 0)
|
||||
|
@ -1460,7 +1460,7 @@ namespace cryptonote { namespace rpc {
|
|||
|
||||
PERF_TIMER(on_getblockcount);
|
||||
{
|
||||
boost::shared_lock<boost::shared_mutex> lock(m_bootstrap_daemon_mutex);
|
||||
std::shared_lock lock{m_bootstrap_daemon_mutex};
|
||||
if (m_should_use_bootstrap_daemon)
|
||||
{
|
||||
res.status = "This command is unsupported for bootstrap daemon";
|
||||
|
@ -1478,7 +1478,7 @@ namespace cryptonote { namespace rpc {
|
|||
|
||||
PERF_TIMER(on_getblockhash);
|
||||
{
|
||||
boost::shared_lock<boost::shared_mutex> lock(m_bootstrap_daemon_mutex);
|
||||
std::shared_lock lock{m_bootstrap_daemon_mutex};
|
||||
if (m_should_use_bootstrap_daemon)
|
||||
{
|
||||
res = "This command is unsupported for bootstrap daemon";
|
||||
|
@ -1596,7 +1596,7 @@ namespace cryptonote { namespace rpc {
|
|||
|
||||
PERF_TIMER(on_submitblock);
|
||||
{
|
||||
boost::shared_lock<boost::shared_mutex> lock(m_bootstrap_daemon_mutex);
|
||||
std::shared_lock lock{m_bootstrap_daemon_mutex};
|
||||
if (m_should_use_bootstrap_daemon)
|
||||
{
|
||||
res.status = "This command is unsupported for bootstrap daemon";
|
||||
|
@ -1715,24 +1715,20 @@ namespace cryptonote { namespace rpc {
|
|||
|
||||
/// All the common (untemplated) code for use_bootstrap_daemon_if_necessary. Returns a held lock
|
||||
/// if we need to bootstrap, an unheld one if we don't.
|
||||
boost::upgrade_lock<boost::shared_mutex> core_rpc_server::should_bootstrap_lock()
|
||||
std::unique_lock<std::shared_mutex> core_rpc_server::should_bootstrap_lock()
|
||||
{
|
||||
// TODO - support bootstrapping via a remote LMQ RPC; requires some argument fiddling
|
||||
boost::upgrade_lock<boost::shared_mutex> lock(m_bootstrap_daemon_mutex);
|
||||
if (!m_should_use_bootstrap_daemon || m_bootstrap_daemon.get() == nullptr)
|
||||
{
|
||||
lock.unlock();
|
||||
return lock;
|
||||
}
|
||||
|
||||
if (m_bootstrap_daemon_address.empty() || !m_should_use_bootstrap_daemon)
|
||||
return {};
|
||||
|
||||
std::unique_lock<std::shared_mutex> lock{m_bootstrap_daemon_mutex};
|
||||
|
||||
auto current_time = std::chrono::system_clock::now();
|
||||
if (!m_p2p.get_payload_object().no_sync() &&
|
||||
current_time - m_bootstrap_height_check_time > 30s) // update every 30s
|
||||
{
|
||||
{
|
||||
boost::upgrade_to_unique_lock<boost::shared_mutex> upgrade_lock(lock);
|
||||
m_bootstrap_height_check_time = current_time;
|
||||
}
|
||||
m_bootstrap_height_check_time = current_time;
|
||||
|
||||
std::optional<uint64_t> bootstrap_daemon_height = m_bootstrap_daemon->get_height();
|
||||
if (!bootstrap_daemon_height)
|
||||
|
@ -1804,10 +1800,7 @@ namespace cryptonote { namespace rpc {
|
|||
if (!success)
|
||||
throw std::runtime_error{"Bootstrap request failed"};
|
||||
|
||||
{
|
||||
boost::upgrade_to_unique_lock<boost::shared_mutex> lock(bs_lock);
|
||||
m_was_bootstrap_ever_used = true;
|
||||
}
|
||||
m_was_bootstrap_ever_used = true;
|
||||
res.untrusted = true;
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -311,14 +311,14 @@ private:
|
|||
bool set_bootstrap_daemon(const std::string &address, const std::string &username_password);
|
||||
bool set_bootstrap_daemon(const std::string &address, const boost::optional<epee::net_utils::http::login> &credentials);
|
||||
void fill_block_header_response(const block& blk, bool orphan_status, uint64_t height, const crypto::hash& hash, block_header_response& response, bool fill_pow_hash);
|
||||
boost::upgrade_lock<boost::shared_mutex> should_bootstrap_lock();
|
||||
std::unique_lock<std::shared_mutex> should_bootstrap_lock();
|
||||
|
||||
template <typename COMMAND_TYPE>
|
||||
bool use_bootstrap_daemon_if_necessary(const typename COMMAND_TYPE::request& req, typename COMMAND_TYPE::response& res);
|
||||
|
||||
core& m_core;
|
||||
nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<cryptonote::core> >& m_p2p;
|
||||
boost::shared_mutex m_bootstrap_daemon_mutex;
|
||||
std::shared_mutex m_bootstrap_daemon_mutex;
|
||||
std::atomic<bool> m_should_use_bootstrap_daemon;
|
||||
std::unique_ptr<bootstrap_daemon> m_bootstrap_daemon;
|
||||
std::chrono::system_clock::time_point m_bootstrap_height_check_time;
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
|
||||
#include <algorithm>
|
||||
#include <boost/thread/locks.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
|
||||
#include "cryptonote_core/cryptonote_core.h"
|
||||
|
||||
|
@ -30,7 +28,7 @@ namespace rpc
|
|||
{
|
||||
static struct D
|
||||
{
|
||||
boost::mutex mutex;
|
||||
std::mutex mutex;
|
||||
std::vector<std::uint64_t> cached_distribution;
|
||||
std::uint64_t cached_from, cached_to, cached_start_height, cached_base;
|
||||
crypto::hash cached_m10_hash;
|
||||
|
@ -38,7 +36,7 @@ namespace rpc
|
|||
bool cached;
|
||||
D(): cached_from(0), cached_to(0), cached_start_height(0), cached_base(0), cached_m10_hash(crypto::null_hash), cached_top_hash(crypto::null_hash), cached(false) {}
|
||||
} d;
|
||||
const boost::unique_lock<boost::mutex> lock(d.mutex);
|
||||
const std::unique_lock lock{d.mutex};
|
||||
|
||||
crypto::hash top_hash = crypto::null_hash;
|
||||
if (d.cached_to < blockchain_height)
|
||||
|
|
|
@ -113,7 +113,7 @@ using sw = cryptonote::simple_wallet;
|
|||
m_auto_refresh_enabled.store(false, std::memory_order_relaxed); \
|
||||
/* stop any background refresh, and take over */ \
|
||||
m_wallet->stop(); \
|
||||
boost::unique_lock<boost::mutex> lock(m_idle_mutex); \
|
||||
std::unique_lock lock{m_idle_mutex}; \
|
||||
m_idle_cond.notify_all(); \
|
||||
LOKI_DEFER { \
|
||||
m_auto_refresh_enabled.store(auto_refresh_enabled, std::memory_order_relaxed); \
|
||||
|
@ -4563,7 +4563,7 @@ bool simple_wallet::close_wallet()
|
|||
m_idle_run.store(false, std::memory_order_relaxed);
|
||||
m_wallet->stop();
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(m_idle_mutex);
|
||||
std::unique_lock lock{m_idle_mutex};
|
||||
m_idle_cond.notify_one();
|
||||
}
|
||||
m_idle_thread.join();
|
||||
|
@ -8579,7 +8579,7 @@ void simple_wallet::wallet_idle_thread()
|
|||
const boost::posix_time::ptime start_time = boost::posix_time::microsec_clock::universal_time();
|
||||
while (true)
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(m_idle_mutex);
|
||||
std::unique_lock lock{m_idle_mutex};
|
||||
if (!m_idle_run.load(std::memory_order_relaxed))
|
||||
break;
|
||||
|
||||
|
|
|
@ -38,6 +38,8 @@
|
|||
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
|
||||
#include <boost/program_options/variables_map.hpp>
|
||||
|
||||
|
@ -432,8 +434,8 @@ namespace cryptonote
|
|||
|
||||
std::atomic<bool> m_idle_run;
|
||||
boost::thread m_idle_thread;
|
||||
boost::mutex m_idle_mutex;
|
||||
boost::condition_variable m_idle_cond;
|
||||
std::mutex m_idle_mutex;
|
||||
std::condition_variable m_idle_cond;
|
||||
|
||||
std::atomic<bool> m_auto_refresh_enabled;
|
||||
bool m_auto_refresh_refreshing;
|
||||
|
|
|
@ -59,14 +59,14 @@ TransactionHistoryImpl::~TransactionHistoryImpl()
|
|||
|
||||
int TransactionHistoryImpl::count() const
|
||||
{
|
||||
boost::shared_lock<boost::shared_mutex> lock(m_historyMutex);
|
||||
std::shared_lock lock{m_historyMutex};
|
||||
int result = m_history.size();
|
||||
return result;
|
||||
}
|
||||
|
||||
TransactionInfo *TransactionHistoryImpl::transaction(int index) const
|
||||
{
|
||||
boost::shared_lock<boost::shared_mutex> lock(m_historyMutex);
|
||||
std::shared_lock lock{m_historyMutex};
|
||||
// sanity check
|
||||
if (index < 0)
|
||||
return nullptr;
|
||||
|
@ -76,7 +76,7 @@ TransactionInfo *TransactionHistoryImpl::transaction(int index) const
|
|||
|
||||
TransactionInfo *TransactionHistoryImpl::transaction(const std::string &id) const
|
||||
{
|
||||
boost::shared_lock<boost::shared_mutex> lock(m_historyMutex);
|
||||
std::shared_lock lock{m_historyMutex};
|
||||
auto itr = std::find_if(m_history.begin(), m_history.end(),
|
||||
[&](const TransactionInfo * ti) {
|
||||
return ti->hash() == id;
|
||||
|
@ -86,7 +86,7 @@ TransactionInfo *TransactionHistoryImpl::transaction(const std::string &id) cons
|
|||
|
||||
std::vector<TransactionInfo *> TransactionHistoryImpl::getAll() const
|
||||
{
|
||||
boost::shared_lock<boost::shared_mutex> lock(m_historyMutex);
|
||||
std::shared_lock lock{m_historyMutex};
|
||||
return m_history;
|
||||
}
|
||||
|
||||
|
@ -101,9 +101,8 @@ static reward_type from_pay_type(tools::pay_type ptype) {
|
|||
void TransactionHistoryImpl::refresh()
|
||||
{
|
||||
// multithreaded access:
|
||||
// boost::lock_guard<boost::mutex> guarg(m_historyMutex);
|
||||
// for "write" access, locking exclusively
|
||||
boost::unique_lock<boost::shared_mutex> lock(m_historyMutex);
|
||||
std::unique_lock lock{m_historyMutex};
|
||||
|
||||
// TODO: configurable values;
|
||||
uint64_t min_height = 0;
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
||||
|
||||
#include "wallet/api/wallet2_api.h"
|
||||
#include <boost/thread/shared_mutex.hpp>
|
||||
#include <shared_mutex>
|
||||
|
||||
namespace Monero {
|
||||
|
||||
|
@ -51,7 +51,7 @@ private:
|
|||
// TransactionHistory is responsible of memory management
|
||||
std::vector<TransactionInfo*> m_history;
|
||||
WalletImpl *m_wallet;
|
||||
mutable boost::shared_mutex m_historyMutex;
|
||||
mutable std::shared_mutex m_historyMutex;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -843,18 +843,18 @@ void WalletImpl::setSeedLanguage(const std::string &arg)
|
|||
|
||||
int WalletImpl::status() const
|
||||
{
|
||||
boost::lock_guard<boost::mutex> l(m_statusMutex);
|
||||
std::lock_guard l{m_statusMutex};
|
||||
return m_status;
|
||||
}
|
||||
|
||||
std::string WalletImpl::errorString() const
|
||||
{
|
||||
boost::lock_guard<boost::mutex> l(m_statusMutex);
|
||||
std::lock_guard l{m_statusMutex};
|
||||
return m_errorString;
|
||||
}
|
||||
|
||||
void WalletImpl::statusWithErrorString(int& status, std::string& errorString) const {
|
||||
boost::lock_guard<boost::mutex> l(m_statusMutex);
|
||||
std::lock_guard l{m_statusMutex};
|
||||
status = m_status;
|
||||
errorString = m_errorString;
|
||||
}
|
||||
|
@ -2119,7 +2119,7 @@ bool WalletImpl::watchOnly() const
|
|||
|
||||
void WalletImpl::clearStatus() const
|
||||
{
|
||||
boost::lock_guard<boost::mutex> l(m_statusMutex);
|
||||
std::lock_guard l{m_statusMutex};
|
||||
m_status = Status_Ok;
|
||||
m_errorString.clear();
|
||||
}
|
||||
|
@ -2136,7 +2136,7 @@ void WalletImpl::setStatusCritical(const std::string& message) const
|
|||
|
||||
void WalletImpl::setStatus(int status, const std::string& message) const
|
||||
{
|
||||
boost::lock_guard<boost::mutex> l(m_statusMutex);
|
||||
std::lock_guard l{m_statusMutex};
|
||||
m_status = status;
|
||||
m_errorString = message;
|
||||
}
|
||||
|
@ -2146,7 +2146,7 @@ void WalletImpl::refreshThreadFunc()
|
|||
LOG_PRINT_L3(__FUNCTION__ << ": starting refresh thread");
|
||||
|
||||
while (true) {
|
||||
boost::mutex::scoped_lock lock(m_refreshMutex);
|
||||
std::unique_lock lock{m_refreshMutex};
|
||||
if (m_refreshThreadDone) {
|
||||
break;
|
||||
}
|
||||
|
@ -2176,7 +2176,7 @@ void WalletImpl::doRefresh()
|
|||
{
|
||||
bool rescan = m_refreshShouldRescan.exchange(false);
|
||||
// synchronizing async and sync refresh calls
|
||||
boost::lock_guard<boost::mutex> guarg(m_refreshMutex2);
|
||||
std::lock_guard guard{m_refreshMutex2};
|
||||
do try {
|
||||
LOG_PRINT_L3(__FUNCTION__ << ": doRefresh, rescan = "<<rescan);
|
||||
// Syncing daemon and refreshing wallet simultaneously is very resource intensive.
|
||||
|
|
|
@ -35,9 +35,9 @@
|
|||
#include "wallet/wallet2.h"
|
||||
|
||||
#include <string>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/thread/condition_variable.hpp>
|
||||
|
||||
|
||||
namespace Monero {
|
||||
|
@ -235,7 +235,7 @@ private:
|
|||
friend class SubaddressAccountImpl;
|
||||
|
||||
std::unique_ptr<tools::wallet2> m_wallet;
|
||||
mutable boost::mutex m_statusMutex;
|
||||
mutable std::mutex m_statusMutex;
|
||||
mutable int m_status;
|
||||
mutable std::string m_errorString;
|
||||
std::string m_password;
|
||||
|
@ -251,11 +251,11 @@ private:
|
|||
std::atomic<int> m_refreshIntervalMillis;
|
||||
std::atomic<bool> m_refreshShouldRescan;
|
||||
// synchronizing refresh loop;
|
||||
boost::mutex m_refreshMutex;
|
||||
std::mutex m_refreshMutex;
|
||||
|
||||
// synchronizing sync and async refresh
|
||||
boost::mutex m_refreshMutex2;
|
||||
boost::condition_variable m_refreshCV;
|
||||
std::mutex m_refreshMutex2;
|
||||
std::condition_variable m_refreshCV;
|
||||
boost::thread m_refreshThread;
|
||||
boost::thread m_longPollThread;
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include "node_rpc_proxy.h"
|
||||
#include "storages/http_abstract_invoke.h"
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
namespace rpc = cryptonote::rpc;
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <numeric>
|
||||
#include <tuple>
|
||||
#include <optional>
|
||||
#include <mutex>
|
||||
#include <boost/format.hpp>
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
|
@ -1655,7 +1656,7 @@ bool wallet2::frozen(const transfer_details &td) const
|
|||
void wallet2::check_acc_out_precomp(const tx_out &o, const crypto::key_derivation &derivation, const std::vector<crypto::key_derivation> &additional_derivations, size_t i, tx_scan_info_t &tx_scan_info) const
|
||||
{
|
||||
hw::device &hwdev = m_account.get_device();
|
||||
boost::unique_lock<hw::device> hwdev_lock (hwdev);
|
||||
std::unique_lock hwdev_lock{hwdev};
|
||||
hwdev.set_mode(hw::device::TRANSACTION_PARSE);
|
||||
if (o.target.type() != typeid(txout_to_key))
|
||||
{
|
||||
|
@ -1925,7 +1926,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
|||
if (tx_cache_data.primary.empty())
|
||||
{
|
||||
hw::device &hwdev = m_account.get_device();
|
||||
boost::unique_lock<hw::device> hwdev_lock (hwdev);
|
||||
std::unique_lock hwdev_lock{hwdev};
|
||||
hw::reset_mode rst(hwdev);
|
||||
|
||||
hwdev.set_mode(hw::device::TRANSACTION_PARSE);
|
||||
|
@ -1992,7 +1993,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
|||
waiter.wait(&tpool);
|
||||
|
||||
hw::device &hwdev = m_account.get_device();
|
||||
boost::unique_lock<hw::device> hwdev_lock (hwdev);
|
||||
std::unique_lock hwdev_lock{hwdev};
|
||||
hwdev.set_mode(hw::device::NONE);
|
||||
for (size_t i = 0; i < tx.vout.size(); ++i)
|
||||
{
|
||||
|
@ -2013,7 +2014,7 @@ void wallet2::process_new_transaction(const crypto::hash &txid, const cryptonote
|
|||
if (tx_scan_info[i].received)
|
||||
{
|
||||
hw::device &hwdev = m_account.get_device();
|
||||
boost::unique_lock<hw::device> hwdev_lock (hwdev);
|
||||
std::unique_lock hwdev_lock{hwdev};
|
||||
hwdev.set_mode(hw::device::NONE);
|
||||
hwdev.conceal_derivation(tx_scan_info[i].received->derivation, tx_pub_key, additional_tx_pub_keys.data, derivation, additional_derivations);
|
||||
scan_output(tx, miner_tx, tx_pub_key, i, tx_scan_info[i], tx_money_got_in_outs, outs, pool, blink);
|
||||
|
@ -2796,7 +2797,7 @@ void wallet2::process_parsed_blocks(uint64_t start_height, const std::vector<cry
|
|||
continue;
|
||||
tpool.submit(&waiter, [&hwdev, &gender, &tx_cache_data, i]() {
|
||||
auto &slot = tx_cache_data[i];
|
||||
boost::unique_lock<hw::device> hwdev_lock(hwdev);
|
||||
std::unique_lock hwdev_lock{hwdev};
|
||||
for (auto &iod: slot.primary)
|
||||
gender(iod);
|
||||
for (auto &iod: slot.additional)
|
||||
|
@ -2941,7 +2942,7 @@ void wallet2::pull_and_parse_next_blocks(uint64_t start_height, uint64_t &blocks
|
|||
parsed_blocks[i].o_indices = std::move(o_indices[i]);
|
||||
}
|
||||
|
||||
boost::mutex error_lock;
|
||||
std::mutex error_lock;
|
||||
for (size_t i = 0; i < blocks.size(); ++i)
|
||||
{
|
||||
parsed_blocks[i].txes.resize(blocks[i].txs.size());
|
||||
|
@ -2950,7 +2951,7 @@ void wallet2::pull_and_parse_next_blocks(uint64_t start_height, uint64_t &blocks
|
|||
tpool.submit(&waiter, [&, i, j](){
|
||||
if (!parse_and_validate_tx_base_from_blob(blocks[i].txs[j], parsed_blocks[i].txes[j]))
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(error_lock);
|
||||
std::lock_guard lock{error_lock};
|
||||
error = true;
|
||||
}
|
||||
}, true);
|
||||
|
@ -10815,7 +10816,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp
|
|||
{
|
||||
//ensure device is let in NONE mode in any case
|
||||
hw::device &hwdev = m_account.get_device();
|
||||
boost::unique_lock<hw::device> hwdev_lock (hwdev);
|
||||
std::unique_lock hwdev_lock{hwdev};
|
||||
hw::reset_mode rst(hwdev);
|
||||
|
||||
bool const is_lns_tx = (tx_params.tx_type == txtype::loki_name_system);
|
||||
|
@ -11517,7 +11518,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_from(const crypton
|
|||
{
|
||||
//ensure device is let in NONE mode in any case
|
||||
hw::device &hwdev = m_account.get_device();
|
||||
boost::unique_lock<hw::device> hwdev_lock (hwdev);
|
||||
std::unique_lock hwdev_lock{hwdev};
|
||||
hw::reset_mode rst(hwdev);
|
||||
|
||||
uint64_t accumulated_fee, accumulated_outputs, accumulated_change;
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#include <boost/serialization/list.hpp>
|
||||
#include <boost/serialization/vector.hpp>
|
||||
#include <boost/serialization/deque.hpp>
|
||||
#include <boost/thread/lock_guard.hpp>
|
||||
#include <atomic>
|
||||
#include <random>
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ namespace
|
|||
virtual int invoke(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, test_levin_connection_context& context)
|
||||
{
|
||||
m_invoke_counter.inc();
|
||||
boost::unique_lock<boost::mutex> lock(m_mutex);
|
||||
std::unique_lock lock{m_mutex};
|
||||
m_last_command = command;
|
||||
m_last_in_buf = std::string((const char*)in_buff.data(), in_buff.size());
|
||||
buff_out = m_invoke_out_buf;
|
||||
|
@ -78,7 +78,7 @@ namespace
|
|||
virtual int notify(int command, const epee::span<const uint8_t> in_buff, test_levin_connection_context& context)
|
||||
{
|
||||
m_notify_counter.inc();
|
||||
boost::unique_lock<boost::mutex> lock(m_mutex);
|
||||
std::unique_lock lock{m_mutex};
|
||||
m_last_command = command;
|
||||
m_last_in_buf = std::string((const char*)in_buff.data(), in_buff.size());
|
||||
return m_return_code;
|
||||
|
@ -124,7 +124,7 @@ namespace
|
|||
call_counter m_new_connection_counter;
|
||||
call_counter m_close_connection_counter;
|
||||
|
||||
boost::mutex m_mutex;
|
||||
std::mutex m_mutex;
|
||||
|
||||
int m_return_code;
|
||||
std::string m_invoke_out_buf;
|
||||
|
@ -152,7 +152,7 @@ namespace
|
|||
virtual bool do_send(epee::byte_slice message)
|
||||
{
|
||||
m_send_counter.inc();
|
||||
boost::unique_lock<boost::mutex> lock(m_mutex);
|
||||
std::unique_lock lock{m_mutex};
|
||||
m_last_send_data.append(reinterpret_cast<const char*>(message.data()), message.size());
|
||||
return m_send_return;
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ namespace
|
|||
size_t send_counter() const { return m_send_counter.get(); }
|
||||
|
||||
const std::string& last_send_data() const { return m_last_send_data; }
|
||||
void reset_last_send_data() { boost::unique_lock<boost::mutex> lock(m_mutex); m_last_send_data.clear(); }
|
||||
void reset_last_send_data() { std::unique_lock lock{m_mutex}; m_last_send_data.clear(); }
|
||||
|
||||
bool send_return() const { return m_send_return; }
|
||||
void send_return(bool v) { m_send_return = v; }
|
||||
|
@ -181,7 +181,7 @@ namespace
|
|||
boost::asio::io_service& m_io_service;
|
||||
|
||||
call_counter m_send_counter;
|
||||
boost::mutex m_mutex;
|
||||
std::mutex m_mutex;
|
||||
|
||||
std::string m_last_send_data;
|
||||
|
||||
|
|
|
@ -35,15 +35,14 @@
|
|||
#include "include_base_utils.h"
|
||||
#include "common/util.h"
|
||||
|
||||
#include <boost/chrono/chrono.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/date_time/posix_time/posix_time.hpp>
|
||||
#include <boost/thread/condition_variable.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <atomic>
|
||||
|
@ -51,9 +50,10 @@
|
|||
|
||||
|
||||
using namespace std;
|
||||
using namespace std::literals;
|
||||
//unsigned int epee::g_test_dbg_lock_sleep = 0;
|
||||
|
||||
namespace Consts
|
||||
namespace
|
||||
{
|
||||
|
||||
|
||||
|
@ -95,8 +95,6 @@ std::string MAINNET_DAEMON_ADDRESS = "localhost:18081";
|
|||
|
||||
|
||||
|
||||
using namespace Consts;
|
||||
|
||||
struct Utils
|
||||
{
|
||||
static void deleteWallet(const std::string & walletname)
|
||||
|
@ -256,7 +254,7 @@ TEST_F(WalletManagerTest, WalletAmountFromString)
|
|||
|
||||
}
|
||||
|
||||
void open_wallet_helper(Monero::WalletManager *wmgr, Monero::Wallet **wallet, const std::string &pass, boost::mutex *mutex)
|
||||
void open_wallet_helper(Monero::WalletManager *wmgr, Monero::Wallet **wallet, const std::string &pass, std::mutex *mutex)
|
||||
{
|
||||
if (mutex)
|
||||
mutex->lock();
|
||||
|
@ -309,7 +307,7 @@ TEST_F(WalletManagerTest, WalletManagerOpensWalletWithPasswordAndReopen)
|
|||
|
||||
Monero::Wallet *wallet2 = nullptr;
|
||||
Monero::Wallet *wallet3 = nullptr;
|
||||
boost::mutex mutex;
|
||||
std::mutex mutex;
|
||||
|
||||
open_wallet_helper(wmgr, &wallet2, wrong_wallet_pass, nullptr);
|
||||
ASSERT_TRUE(wallet2 != nullptr);
|
||||
|
@ -791,12 +789,12 @@ struct MyWalletListener : public Monero::WalletListener
|
|||
Monero::Wallet * wallet;
|
||||
uint64_t total_tx;
|
||||
uint64_t total_rx;
|
||||
boost::mutex mutex;
|
||||
boost::condition_variable cv_send;
|
||||
boost::condition_variable cv_receive;
|
||||
boost::condition_variable cv_update;
|
||||
boost::condition_variable cv_refresh;
|
||||
boost::condition_variable cv_newblock;
|
||||
std::mutex mutex;
|
||||
std::condition_variable cv_send;
|
||||
std::condition_variable cv_receive;
|
||||
std::condition_variable cv_update;
|
||||
std::condition_variable cv_refresh;
|
||||
std::condition_variable cv_newblock;
|
||||
bool send_triggered;
|
||||
bool receive_triggered;
|
||||
bool newblock_triggered;
|
||||
|
@ -886,9 +884,8 @@ TEST_F(WalletTest2, WalletCallBackRefreshedSync)
|
|||
ASSERT_TRUE(wallet_src->init(TESTNET_DAEMON_ADDRESS, 0));
|
||||
ASSERT_TRUE(wallet_src_listener->refresh_triggered);
|
||||
ASSERT_TRUE(wallet_src->connected());
|
||||
boost::chrono::seconds wait_for = boost::chrono::seconds(60*3);
|
||||
boost::unique_lock<boost::mutex> lock (wallet_src_listener->mutex);
|
||||
wallet_src_listener->cv_refresh.wait_for(lock, wait_for);
|
||||
std::unique_lock lock{wallet_src_listener->mutex};
|
||||
wallet_src_listener->cv_refresh.wait_for(lock, 3min);
|
||||
wmgr->closeWallet(wallet_src);
|
||||
}
|
||||
|
||||
|
@ -901,12 +898,11 @@ TEST_F(WalletTest2, WalletCallBackRefreshedAsync)
|
|||
Monero::Wallet * wallet_src = wmgr->openWallet(CURRENT_SRC_WALLET, TESTNET_WALLET_PASS, Monero::NetworkType::TESTNET);
|
||||
MyWalletListener * wallet_src_listener = new MyWalletListener(wallet_src);
|
||||
|
||||
boost::chrono::seconds wait_for = boost::chrono::seconds(20);
|
||||
boost::unique_lock<boost::mutex> lock (wallet_src_listener->mutex);
|
||||
std::unique_lock lock{wallet_src_listener->mutex};
|
||||
wallet_src->init(MAINNET_DAEMON_ADDRESS, 0);
|
||||
wallet_src->startRefresh();
|
||||
std::cerr << "TEST: waiting on refresh lock...\n";
|
||||
wallet_src_listener->cv_refresh.wait_for(lock, wait_for);
|
||||
wallet_src_listener->cv_refresh.wait_for(lock, 20s);
|
||||
std::cerr << "TEST: refresh lock acquired...\n";
|
||||
ASSERT_TRUE(wallet_src_listener->refresh_triggered);
|
||||
ASSERT_TRUE(wallet_src->connected());
|
||||
|
@ -942,10 +938,9 @@ TEST_F(WalletTest2, WalletCallbackSent)
|
|||
ASSERT_TRUE(tx->status() == Monero::PendingTransaction::Status_Ok);
|
||||
ASSERT_TRUE(tx->commit());
|
||||
|
||||
boost::chrono::seconds wait_for = boost::chrono::seconds(60*3);
|
||||
boost::unique_lock<boost::mutex> lock (wallet_src_listener->mutex);
|
||||
std::unique_lock lock{wallet_src_listener->mutex};
|
||||
std::cerr << "TEST: waiting on send lock...\n";
|
||||
wallet_src_listener->cv_send.wait_for(lock, wait_for);
|
||||
wallet_src_listener->cv_send.wait_for(lock, 3min);
|
||||
std::cerr << "TEST: send lock acquired...\n";
|
||||
ASSERT_TRUE(wallet_src_listener->send_triggered);
|
||||
ASSERT_TRUE(wallet_src_listener->update_triggered);
|
||||
|
@ -984,10 +979,9 @@ TEST_F(WalletTest2, WalletCallbackReceived)
|
|||
ASSERT_TRUE(tx->status() == Monero::PendingTransaction::Status_Ok);
|
||||
ASSERT_TRUE(tx->commit());
|
||||
|
||||
boost::chrono::seconds wait_for = boost::chrono::seconds(60*4);
|
||||
boost::unique_lock<boost::mutex> lock (wallet_dst_listener->mutex);
|
||||
std::unique_lock lock{wallet_dst_listener->mutex};
|
||||
std::cerr << "TEST: waiting on receive lock...\n";
|
||||
wallet_dst_listener->cv_receive.wait_for(lock, wait_for);
|
||||
wallet_dst_listener->cv_receive.wait_for(lock, 4min);
|
||||
std::cerr << "TEST: receive lock acquired...\n";
|
||||
ASSERT_TRUE(wallet_dst_listener->receive_triggered);
|
||||
ASSERT_TRUE(wallet_dst_listener->update_triggered);
|
||||
|
@ -1017,10 +1011,9 @@ TEST_F(WalletTest2, WalletCallbackNewBlock)
|
|||
std::unique_ptr<MyWalletListener> wallet_listener (new MyWalletListener(wallet_src));
|
||||
|
||||
// wait max 4 min for new block
|
||||
boost::chrono::seconds wait_for = boost::chrono::seconds(60*4);
|
||||
boost::unique_lock<boost::mutex> lock (wallet_listener->mutex);
|
||||
std::unique_lock lock{wallet_listener->mutex};
|
||||
std::cerr << "TEST: waiting on newblock lock...\n";
|
||||
wallet_listener->cv_newblock.wait_for(lock, wait_for);
|
||||
wallet_listener->cv_newblock.wait_for(lock, 4min);
|
||||
std::cerr << "TEST: newblock lock acquired...\n";
|
||||
ASSERT_TRUE(wallet_listener->newblock_triggered);
|
||||
uint64_t bc2 = wallet_src->blockChainHeight();
|
||||
|
@ -1049,14 +1042,13 @@ TEST_F(WalletManagerMainnetTest, CreateOpenAndRefreshWalletMainNetSync)
|
|||
|
||||
TEST_F(WalletManagerMainnetTest, CreateAndRefreshWalletMainNetAsync)
|
||||
{
|
||||
// supposing 120 seconds should be enough for fast refresh
|
||||
int SECONDS_TO_REFRESH = 120;
|
||||
// supposing 2 minutes should be enough for fast refresh
|
||||
constexpr auto wait_for = 2min;
|
||||
|
||||
Monero::Wallet * wallet = wmgr->createWallet(WALLET_NAME_MAINNET, "", WALLET_LANG, Monero::NetworkType::MAINNET);
|
||||
std::unique_ptr<MyWalletListener> wallet_listener (new MyWalletListener(wallet));
|
||||
|
||||
boost::chrono::seconds wait_for = boost::chrono::seconds(SECONDS_TO_REFRESH);
|
||||
boost::unique_lock<boost::mutex> lock (wallet_listener->mutex);
|
||||
std::unique_lock lock{wallet_listener->mutex};
|
||||
wallet->init(MAINNET_DAEMON_ADDRESS, 0);
|
||||
wallet->startRefresh();
|
||||
std::cerr << "TEST: waiting on refresh lock...\n";
|
||||
|
@ -1073,16 +1065,16 @@ TEST_F(WalletManagerMainnetTest, CreateAndRefreshWalletMainNetAsync)
|
|||
TEST_F(WalletManagerMainnetTest, OpenAndRefreshWalletMainNetAsync)
|
||||
{
|
||||
|
||||
// supposing 120 seconds should be enough for fast refresh
|
||||
int SECONDS_TO_REFRESH = 120;
|
||||
// supposing 2 minutes should be enough for fast refresh
|
||||
constexpr auto wait_for = 2min;
|
||||
|
||||
Monero::Wallet * wallet = wmgr->createWallet(WALLET_NAME_MAINNET, "", WALLET_LANG, Monero::NetworkType::MAINNET);
|
||||
wmgr->closeWallet(wallet);
|
||||
wallet = wmgr->openWallet(WALLET_NAME_MAINNET, "", Monero::NetworkType::MAINNET);
|
||||
|
||||
std::unique_ptr<MyWalletListener> wallet_listener (new MyWalletListener(wallet));
|
||||
|
||||
boost::chrono::seconds wait_for = boost::chrono::seconds(SECONDS_TO_REFRESH);
|
||||
boost::unique_lock<boost::mutex> lock (wallet_listener->mutex);
|
||||
std::unique_lock lock{wallet_listener->mutex};
|
||||
wallet->init(MAINNET_DAEMON_ADDRESS, 0);
|
||||
wallet->startRefresh();
|
||||
std::cerr << "TEST: waiting on refresh lock...\n";
|
||||
|
@ -1100,8 +1092,8 @@ TEST_F(WalletManagerMainnetTest, OpenAndRefreshWalletMainNetAsync)
|
|||
TEST_F(WalletManagerMainnetTest, RecoverAndRefreshWalletMainNetAsync)
|
||||
{
|
||||
|
||||
// supposing 120 seconds should be enough for fast refresh
|
||||
int SECONDS_TO_REFRESH = 120;
|
||||
// supposing 2 minutes should be enough for fast refresh
|
||||
constexpr auto wait_for = 2min;
|
||||
Monero::Wallet * wallet = wmgr->createWallet(WALLET_NAME_MAINNET, "", WALLET_LANG, Monero::NetworkType::MAINNET);
|
||||
std::string seed = wallet->seed();
|
||||
std::string address = wallet->mainAddress();
|
||||
|
@ -1115,8 +1107,7 @@ TEST_F(WalletManagerMainnetTest, RecoverAndRefreshWalletMainNetAsync)
|
|||
ASSERT_TRUE(wallet->status() == Monero::Wallet::Status_Ok);
|
||||
ASSERT_TRUE(wallet->mainAddress() == address);
|
||||
std::unique_ptr<MyWalletListener> wallet_listener (new MyWalletListener(wallet));
|
||||
boost::chrono::seconds wait_for = boost::chrono::seconds(SECONDS_TO_REFRESH);
|
||||
boost::unique_lock<boost::mutex> lock (wallet_listener->mutex);
|
||||
std::unique_lock lock{wallet_listener->mutex};
|
||||
wallet->init(MAINNET_DAEMON_ADDRESS, 0);
|
||||
wallet->startRefresh();
|
||||
std::cerr << "TEST: waiting on refresh lock...\n";
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
//
|
||||
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
||||
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <memory>
|
||||
|
||||
|
@ -60,7 +59,7 @@ namespace
|
|||
|
||||
//std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||
|
||||
boost::unique_lock<boost::mutex> lock(m_open_close_test_mutex);
|
||||
std::unique_lock 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));
|
||||
|
@ -71,7 +70,7 @@ namespace
|
|||
{
|
||||
test_levin_commands_handler::on_connection_close(context);
|
||||
|
||||
boost::unique_lock<boost::mutex> lock(m_open_close_test_mutex);
|
||||
std::unique_lock lock{m_open_close_test_mutex};
|
||||
if (context.m_connection_id == m_open_close_test_conn_id)
|
||||
{
|
||||
LOG_PRINT_L0("Stop open/close test");
|
||||
|
@ -117,7 +116,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)
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(m_open_close_test_mutex);
|
||||
std::unique_lock 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 << ")");
|
||||
|
@ -210,7 +209,7 @@ namespace
|
|||
test_tcp_server& m_tcp_server;
|
||||
|
||||
boost::uuids::uuid m_open_close_test_conn_id;
|
||||
boost::mutex m_open_close_test_mutex;
|
||||
std::mutex m_open_close_test_mutex;
|
||||
std::unique_ptr<open_close_test_helper> m_open_close_test_helper;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
//
|
||||
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
||||
|
||||
#include <boost/chrono/chrono.hpp>
|
||||
#include <boost/thread/condition_variable.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
|
@ -38,6 +38,8 @@
|
|||
#include "string_tools.h"
|
||||
#include "net/abstract_tcp_server2.h"
|
||||
|
||||
using namespace std::literals;
|
||||
|
||||
namespace
|
||||
{
|
||||
const uint32_t test_server_port = 5626;
|
||||
|
@ -87,13 +89,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));
|
||||
|
||||
boost::mutex mtx;
|
||||
boost::condition_variable cond;
|
||||
std::mutex mtx;
|
||||
std::condition_variable cond;
|
||||
int counter = 0;
|
||||
|
||||
auto counter_incrementer = [&counter, &cond, &mtx]()
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mtx);
|
||||
std::unique_lock lock{mtx};
|
||||
++counter;
|
||||
if (4 <= counter)
|
||||
{
|
||||
|
@ -109,8 +111,8 @@ TEST(boosted_tcp_server, worker_threads_are_exception_resistant)
|
|||
ASSERT_TRUE(srv.async_call([&counter_incrementer]() { counter_incrementer(); throw 4; }));
|
||||
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mtx);
|
||||
ASSERT_NE(boost::cv_status::timeout, cond.wait_for(lock, boost::chrono::seconds(5)));
|
||||
std::unique_lock lock{mtx};
|
||||
ASSERT_NE(std::cv_status::timeout, cond.wait_for(lock, 5s));
|
||||
ASSERT_EQ(4, counter);
|
||||
}
|
||||
|
||||
|
@ -123,8 +125,8 @@ TEST(boosted_tcp_server, worker_threads_are_exception_resistant)
|
|||
ASSERT_TRUE(srv.async_call(counter_incrementer));
|
||||
|
||||
{
|
||||
boost::unique_lock<boost::mutex> lock(mtx);
|
||||
ASSERT_NE(boost::cv_status::timeout, cond.wait_for(lock, boost::chrono::seconds(5)));
|
||||
std::unique_lock lock{mtx};
|
||||
ASSERT_NE(std::cv_status::timeout, cond.wait_for(lock, 5s));
|
||||
ASSERT_EQ(4, counter);
|
||||
}
|
||||
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
//
|
||||
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
|
||||
|
||||
#include <boost/thread/mutex.hpp>
|
||||
#include <boost/thread/thread.hpp>
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
@ -59,7 +58,7 @@ namespace
|
|||
virtual int invoke(int command, const epee::span<const uint8_t> in_buff, std::string& buff_out, test_levin_connection_context& context)
|
||||
{
|
||||
m_invoke_counter.inc();
|
||||
boost::unique_lock<boost::mutex> lock(m_mutex);
|
||||
std::unique_lock lock{m_mutex};
|
||||
m_last_command = command;
|
||||
m_last_in_buf = std::string((const char*)in_buff.data(), in_buff.size());
|
||||
buff_out = m_invoke_out_buf;
|
||||
|
@ -69,7 +68,7 @@ namespace
|
|||
virtual int notify(int command, const epee::span<const uint8_t> in_buff, test_levin_connection_context& context)
|
||||
{
|
||||
m_notify_counter.inc();
|
||||
boost::unique_lock<boost::mutex> lock(m_mutex);
|
||||
std::unique_lock lock{m_mutex};
|
||||
m_last_command = command;
|
||||
m_last_in_buf = std::string((const char*)in_buff.data(), in_buff.size());
|
||||
return m_return_code;
|
||||
|
@ -115,7 +114,7 @@ namespace
|
|||
unit_test::call_counter m_new_connection_counter;
|
||||
unit_test::call_counter m_close_connection_counter;
|
||||
|
||||
boost::mutex m_mutex;
|
||||
std::mutex m_mutex;
|
||||
|
||||
int m_return_code;
|
||||
std::string m_invoke_out_buf;
|
||||
|
@ -144,7 +143,7 @@ namespace
|
|||
{
|
||||
//std::cout << "test_connection::do_send()" << std::endl;
|
||||
m_send_counter.inc();
|
||||
boost::unique_lock<boost::mutex> lock(m_mutex);
|
||||
std::unique_lock lock{m_mutex};
|
||||
m_last_send_data.append(reinterpret_cast<const char*>(message.data()), message.size());
|
||||
return m_send_return;
|
||||
}
|
||||
|
@ -160,7 +159,7 @@ namespace
|
|||
size_t send_counter() const { return m_send_counter.get(); }
|
||||
|
||||
const std::string& last_send_data() const { return m_last_send_data; }
|
||||
void reset_last_send_data() { boost::unique_lock<boost::mutex> lock(m_mutex); m_last_send_data.clear(); }
|
||||
void reset_last_send_data() { std::unique_lock lock{m_mutex}; m_last_send_data.clear(); }
|
||||
|
||||
bool send_return() const { return m_send_return; }
|
||||
void send_return(bool v) { m_send_return = v; }
|
||||
|
@ -173,7 +172,7 @@ namespace
|
|||
test_levin_connection_context m_context;
|
||||
|
||||
unit_test::call_counter m_send_counter;
|
||||
boost::mutex m_mutex;
|
||||
std::mutex m_mutex;
|
||||
|
||||
std::string m_last_send_data;
|
||||
|
||||
|
|
Loading…
Reference in New Issue