Merge pull request #712
66c2fc7
Need to link boost::chrono in more places now (Howard Chu)b937a2c
Use boost::thread instead of std::thread (Howard Chu)
This commit is contained in:
commit
dfd0e9c97d
|
@ -65,7 +65,7 @@ namespace epee
|
||||||
if (state_eos == m_read_status)
|
if (state_eos == m_read_status)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::unique_lock<std::mutex> lock(m_response_mutex);
|
boost::unique_lock<boost::mutex> lock(m_response_mutex);
|
||||||
while (state_init == m_read_status)
|
while (state_init == m_read_status)
|
||||||
{
|
{
|
||||||
m_response_cv.wait(lock);
|
m_response_cv.wait(lock);
|
||||||
|
@ -104,7 +104,7 @@ namespace epee
|
||||||
private:
|
private:
|
||||||
bool start_read()
|
bool start_read()
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(m_request_mutex);
|
boost::unique_lock<boost::mutex> lock(m_request_mutex);
|
||||||
if (!m_run.load(std::memory_order_relaxed) || m_has_read_request)
|
if (!m_run.load(std::memory_order_relaxed) || m_has_read_request)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ namespace epee
|
||||||
|
|
||||||
bool wait_read()
|
bool wait_read()
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(m_request_mutex);
|
boost::unique_lock<boost::mutex> lock(m_request_mutex);
|
||||||
while (m_run.load(std::memory_order_relaxed) && !m_has_read_request)
|
while (m_run.load(std::memory_order_relaxed) && !m_has_read_request)
|
||||||
{
|
{
|
||||||
m_request_cv.wait(lock);
|
m_request_cv.wait(lock);
|
||||||
|
@ -188,7 +188,7 @@ namespace epee
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(m_response_mutex);
|
boost::unique_lock<boost::mutex> lock(m_response_mutex);
|
||||||
if (m_run.load(std::memory_order_relaxed))
|
if (m_run.load(std::memory_order_relaxed))
|
||||||
{
|
{
|
||||||
m_line = std::move(line);
|
m_line = std::move(line);
|
||||||
|
@ -220,10 +220,10 @@ namespace epee
|
||||||
bool m_has_read_request;
|
bool m_has_read_request;
|
||||||
t_state m_read_status;
|
t_state m_read_status;
|
||||||
|
|
||||||
std::mutex m_request_mutex;
|
boost::mutex m_request_mutex;
|
||||||
std::mutex m_response_mutex;
|
boost::mutex m_response_mutex;
|
||||||
std::condition_variable m_request_cv;
|
boost::condition_variable m_request_cv;
|
||||||
std::condition_variable m_response_cv;
|
boost::condition_variable m_response_cv;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -153,8 +153,8 @@ namespace net_utils
|
||||||
// for calculate speed (last 60 sec)
|
// for calculate speed (last 60 sec)
|
||||||
network_throttle m_throttle_speed_in;
|
network_throttle m_throttle_speed_in;
|
||||||
network_throttle m_throttle_speed_out;
|
network_throttle m_throttle_speed_out;
|
||||||
std::mutex m_throttle_speed_in_mutex;
|
boost::mutex m_throttle_speed_in_mutex;
|
||||||
std::mutex m_throttle_speed_out_mutex;
|
boost::mutex m_throttle_speed_out_mutex;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void setRpcStation();
|
void setRpcStation();
|
||||||
|
@ -307,7 +307,7 @@ namespace net_utils
|
||||||
/// The next connection to be accepted
|
/// The next connection to be accepted
|
||||||
connection_ptr new_connection_;
|
connection_ptr new_connection_;
|
||||||
|
|
||||||
std::mutex connections_mutex;
|
boost::mutex connections_mutex;
|
||||||
std::deque<std::pair<boost::system_time, connection_ptr>> connections_;
|
std::deque<std::pair<boost::system_time, connection_ptr>> connections_;
|
||||||
|
|
||||||
}; // class <>boosted_tcp_server
|
}; // class <>boosted_tcp_server
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
#include <boost/utility/value_init.hpp>
|
#include <boost/utility/value_init.hpp>
|
||||||
#include <boost/asio/deadline_timer.hpp>
|
#include <boost/asio/deadline_timer.hpp>
|
||||||
#include <boost/date_time/posix_time/posix_time.hpp> // TODO
|
#include <boost/date_time/posix_time/posix_time.hpp> // TODO
|
||||||
#include <boost/thread/thread.hpp> // TODO
|
#include <boost/thread/v2/thread.hpp> // TODO
|
||||||
#include "misc_language.h"
|
#include "misc_language.h"
|
||||||
#include "pragma_comp_defs.h"
|
#include "pragma_comp_defs.h"
|
||||||
|
|
||||||
|
@ -294,7 +294,7 @@ PRAGMA_WARNING_DISABLE_VS(4355)
|
||||||
if (delay > 0) {
|
if (delay > 0) {
|
||||||
long int ms = (long int)(delay * 100);
|
long int ms = (long int)(delay * 100);
|
||||||
epee::net_utils::data_logger::get_instance().add_data("sleep_down", ms);
|
epee::net_utils::data_logger::get_instance().add_data("sleep_down", ms);
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(ms));
|
boost::this_thread::sleep_for(boost::chrono::milliseconds(ms));
|
||||||
}
|
}
|
||||||
} while(delay > 0);
|
} while(delay > 0);
|
||||||
} // any form of sleeping
|
} // any form of sleeping
|
||||||
|
|
|
@ -30,11 +30,11 @@
|
||||||
#ifndef __WINH_OBJ_H__
|
#ifndef __WINH_OBJ_H__
|
||||||
#define __WINH_OBJ_H__
|
#define __WINH_OBJ_H__
|
||||||
|
|
||||||
|
#include <boost/chrono/duration.hpp>
|
||||||
#include <boost/thread/locks.hpp>
|
#include <boost/thread/locks.hpp>
|
||||||
#include <boost/thread/mutex.hpp>
|
#include <boost/thread/mutex.hpp>
|
||||||
#include <boost/thread/recursive_mutex.hpp>
|
#include <boost/thread/recursive_mutex.hpp>
|
||||||
#include <thread>
|
#include <boost/thread/v2/thread.hpp>
|
||||||
#include <chrono>
|
|
||||||
|
|
||||||
namespace epee
|
namespace epee
|
||||||
{
|
{
|
||||||
|
@ -224,10 +224,10 @@ namespace epee
|
||||||
#define SHARED_CRITICAL_REGION_BEGIN(x) { shared_guard critical_region_var(x)
|
#define SHARED_CRITICAL_REGION_BEGIN(x) { shared_guard critical_region_var(x)
|
||||||
#define EXCLUSIVE_CRITICAL_REGION_BEGIN(x) { exclusive_guard critical_region_var(x)
|
#define EXCLUSIVE_CRITICAL_REGION_BEGIN(x) { exclusive_guard critical_region_var(x)
|
||||||
|
|
||||||
#define CRITICAL_REGION_LOCAL(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_LOCAL(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_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_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) {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_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) { 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) { 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_END() }
|
#define CRITICAL_REGION_END() }
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,11 @@
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <thread>
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <mutex>
|
#include <boost/thread.hpp>
|
||||||
|
#include <boost/thread/mutex.hpp>
|
||||||
|
#include <boost/thread/recursive_mutex.hpp>
|
||||||
|
#include <boost/thread/lock_guard.hpp>
|
||||||
|
|
||||||
|
|
||||||
// list of thigs from libraries that we pull into namespace nOT::nNewcli
|
// list of thigs from libraries that we pull into namespace nOT::nNewcli
|
||||||
|
@ -45,8 +47,7 @@
|
||||||
using std::shared_ptr; \
|
using std::shared_ptr; \
|
||||||
using std::weak_ptr; \
|
using std::weak_ptr; \
|
||||||
using std::enable_shared_from_this; \
|
using std::enable_shared_from_this; \
|
||||||
using std::mutex; \
|
using boost::lock_guard; \
|
||||||
using std::lock_guard; \
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
#include "utils.hpp"
|
#include "utils.hpp"
|
||||||
|
|
||||||
|
@ -129,7 +130,7 @@ std::string get_current_time() {
|
||||||
|
|
||||||
cNullstream g_nullstream; // extern a stream that does nothing (eats/discards data)
|
cNullstream g_nullstream; // extern a stream that does nothing (eats/discards data)
|
||||||
|
|
||||||
std::recursive_mutex gLoggerGuard; // extern
|
boost::recursive_mutex gLoggerGuard; // extern
|
||||||
std::atomic<int> gLoggerGuardDepth; // extern
|
std::atomic<int> gLoggerGuardDepth; // extern
|
||||||
|
|
||||||
std::atomic<int> & gLoggerGuardDepth_Get() {
|
std::atomic<int> & gLoggerGuardDepth_Get() {
|
||||||
|
@ -303,7 +304,7 @@ mPid2Number_Biggest(0)
|
||||||
mIsBroken=false; // ok, constr. succeeded, so string is not broken now
|
mIsBroken=false; // ok, constr. succeeded, so string is not broken now
|
||||||
|
|
||||||
// this is here, because it could be using logging itself to log creation of first thread/PID etc
|
// this is here, because it could be using logging itself to log creation of first thread/PID etc
|
||||||
Thread2Number( std::this_thread::get_id() ); // convert current id to short number, useful to reserve a number so that main thread is usually called 1
|
Thread2Number( boost::this_thread::get_id() ); // convert current id to short number, useful to reserve a number so that main thread is usually called 1
|
||||||
Pid2Number( getpid() ); // add this proces ID as first one
|
Pid2Number( getpid() ); // add this proces ID as first one
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,7 +349,7 @@ std::ostream & cLogger::write_stream(int level, const std::string & channel ) {
|
||||||
output << windows_stream(level);
|
output << windows_stream(level);
|
||||||
#endif
|
#endif
|
||||||
output << icon(level) << ' ';
|
output << icon(level) << ' ';
|
||||||
std::thread::id this_id = std::this_thread::get_id();
|
boost::thread::id this_id = boost::this_thread::get_id();
|
||||||
output << "{" << Thread2Number(this_id) << "}";
|
output << "{" << Thread2Number(this_id) << "}";
|
||||||
auto nicePid = Pid2Number(getpid());
|
auto nicePid = Pid2Number(getpid());
|
||||||
if (nicePid>0) output << " {p" << nicePid << "}";
|
if (nicePid>0) output << " {p" << nicePid << "}";
|
||||||
|
@ -517,7 +518,7 @@ std::string cLogger::endline() const {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int cLogger::Thread2Number(const std::thread::id id) {
|
int cLogger::Thread2Number(const boost::thread::id id) {
|
||||||
auto found = mThread2Number.find( id );
|
auto found = mThread2Number.find( id );
|
||||||
if (found == mThread2Number.end()) { // new one
|
if (found == mThread2Number.end()) { // new one
|
||||||
mThread2Number_Biggest++;
|
mThread2Number_Biggest++;
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
// #define opt_debug_debug
|
// #define opt_debug_debug
|
||||||
|
|
||||||
#ifdef opt_debug_debug
|
#ifdef opt_debug_debug
|
||||||
#define _dbg_dbg(X) do { std::cerr<<"_dbg_dbg: " << OT_CODE_STAMP << " {thread=" << std::this_thread::get_id()<<"} " \
|
#define _dbg_dbg(X) do { std::cerr<<"_dbg_dbg: " << OT_CODE_STAMP << " {thread=" << boost::this_thread::get_id()<<"} " \
|
||||||
<< " {pid="<<getpid()<<"} " << ": " << X << std::endl; } while(0)
|
<< " {pid="<<getpid()<<"} " << ": " << X << std::endl; } while(0)
|
||||||
#else
|
#else
|
||||||
#define _dbg_dbg(X) do { } while(0)
|
#define _dbg_dbg(X) do { } while(0)
|
||||||
|
@ -79,7 +79,7 @@ extern cNullstream g_nullstream; // a stream that does nothing (eats/discards da
|
||||||
|
|
||||||
// TODO make _dbg_ignore thread-safe everywhere
|
// TODO make _dbg_ignore thread-safe everywhere
|
||||||
|
|
||||||
extern std::recursive_mutex gLoggerGuard; // the mutex guarding logging/debugging code e.g. protecting streams, files, etc
|
extern boost::recursive_mutex gLoggerGuard; // the mutex guarding logging/debugging code e.g. protecting streams, files, etc
|
||||||
|
|
||||||
std::atomic<int> & gLoggerGuardDepth_Get(); // getter for the global singleton of counter (it guarantees initializing it to 0). This counter shows the current recursion (re-entrant) level of debug macros.
|
std::atomic<int> & gLoggerGuardDepth_Get(); // getter for the global singleton of counter (it guarantees initializing it to 0). This counter shows the current recursion (re-entrant) level of debug macros.
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ std::atomic<int> & gLoggerGuardDepth_Get(); // getter for the global singleton o
|
||||||
_dbg_dbg("WRITE DEBUG: LEVEL="<<LEVEL<<" VAR: " << VAR ); \
|
_dbg_dbg("WRITE DEBUG: LEVEL="<<LEVEL<<" VAR: " << VAR ); \
|
||||||
auto level=LEVEL; short int part=0; \
|
auto level=LEVEL; short int part=0; \
|
||||||
try { \
|
try { \
|
||||||
std::lock_guard<std::recursive_mutex> mutex_guard( nOT::nUtils::gLoggerGuard ); \
|
boost::lock_guard<boost::recursive_mutex> mutex_guard( nOT::nUtils::gLoggerGuard ); \
|
||||||
part=1; \
|
part=1; \
|
||||||
try { \
|
try { \
|
||||||
++nOT::nUtils::gLoggerGuardDepth_Get(); \
|
++nOT::nUtils::gLoggerGuardDepth_Get(); \
|
||||||
|
@ -111,7 +111,7 @@ std::atomic<int> & gLoggerGuardDepth_Get(); // getter for the global singleton o
|
||||||
_dbg_dbg("WRITE DEBUG: LEVEL="<<LEVEL<<" CHANNEL="<<CHANNEL<<" VAR: " << VAR ); \
|
_dbg_dbg("WRITE DEBUG: LEVEL="<<LEVEL<<" CHANNEL="<<CHANNEL<<" VAR: " << VAR ); \
|
||||||
auto level=LEVEL; short int part=0; \
|
auto level=LEVEL; short int part=0; \
|
||||||
try { \
|
try { \
|
||||||
std::lock_guard<std::recursive_mutex> mutex_guard( nOT::nUtils::gLoggerGuard ); \
|
boost::lock_guard<boost::recursive_mutex> mutex_guard( nOT::nUtils::gLoggerGuard ); \
|
||||||
part=1; \
|
part=1; \
|
||||||
try { \
|
try { \
|
||||||
++nOT::nUtils::gLoggerGuardDepth_Get(); \
|
++nOT::nUtils::gLoggerGuardDepth_Get(); \
|
||||||
|
@ -253,9 +253,9 @@ class cLogger {
|
||||||
void OpenNewChannel_(const std::string & channel); ///< internal function, will throw in case of problems
|
void OpenNewChannel_(const std::string & channel); ///< internal function, will throw in case of problems
|
||||||
std::string GetLogBaseDir() const;
|
std::string GetLogBaseDir() const;
|
||||||
|
|
||||||
std::map< std::thread::id , int > mThread2Number; ///< change long thread IDs into a short nice number to show
|
std::map< boost::thread::id , int > mThread2Number; ///< change long thread IDs into a short nice number to show
|
||||||
int mThread2Number_Biggest; ///< current biggest value held there (biggest key) - works as growing-only counter basically
|
int mThread2Number_Biggest; ///< current biggest value held there (biggest key) - works as growing-only counter basically
|
||||||
int Thread2Number(const std::thread::id id); ///< convert the system's thread id into a nice short our id; make one if new thread
|
int Thread2Number(const boost::thread::id id); ///< convert the system's thread id into a nice short our id; make one if new thread
|
||||||
|
|
||||||
std::map< t_anypid , int > mPid2Number; ///< change long proces PID into a short nice number to show
|
std::map< t_anypid , int > mPid2Number; ///< change long proces PID into a short nice number to show
|
||||||
int mPid2Number_Biggest; ///< current biggest value held there (biggest key) - works as growing-only counter basically
|
int mPid2Number_Biggest; ///< current biggest value held there (biggest key) - works as growing-only counter basically
|
||||||
|
|
|
@ -65,6 +65,7 @@ target_link_libraries(blockchain_db
|
||||||
crypto
|
crypto
|
||||||
cryptonote_core
|
cryptonote_core
|
||||||
${Boost_DATE_TIME_LIBRARY}
|
${Boost_DATE_TIME_LIBRARY}
|
||||||
|
${Boost_CHRONO_LIBRARY}
|
||||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
||||||
${Boost_SERIALIZATION_LIBRARY}
|
${Boost_SERIALIZATION_LIBRARY}
|
||||||
${LMDB_LIBRARY}
|
${LMDB_LIBRARY}
|
||||||
|
|
|
@ -135,7 +135,7 @@ const unsigned int DB_BUFFER_LENGTH = 32 * MB;
|
||||||
const unsigned int DB_DEF_CACHESIZE = 256 * MB;
|
const unsigned int DB_DEF_CACHESIZE = 256 * MB;
|
||||||
|
|
||||||
#if defined(BDB_BULK_CAN_THREAD)
|
#if defined(BDB_BULK_CAN_THREAD)
|
||||||
const unsigned int DB_BUFFER_COUNT = std::thread::hardware_concurrency();
|
const unsigned int DB_BUFFER_COUNT = boost::thread::hardware_concurrency();
|
||||||
#else
|
#else
|
||||||
const unsigned int DB_BUFFER_COUNT = 1;
|
const unsigned int DB_BUFFER_COUNT = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -130,7 +130,7 @@ public:
|
||||||
|
|
||||||
T acquire_buffer()
|
T acquire_buffer()
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(m_lock);
|
boost::unique_lock<boost::mutex> lock(m_lock);
|
||||||
m_cv.wait(lock, [&]{ return m_count > 0; });
|
m_cv.wait(lock, [&]{ return m_count > 0; });
|
||||||
|
|
||||||
--m_count;
|
--m_count;
|
||||||
|
@ -154,7 +154,7 @@ public:
|
||||||
|
|
||||||
void release_buffer(T buffer)
|
void release_buffer(T buffer)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(m_lock);
|
boost::unique_lock<boost::mutex> lock(m_lock);
|
||||||
|
|
||||||
assert(buffer != nullptr);
|
assert(buffer != nullptr);
|
||||||
auto it = m_buffer_map.find(buffer);
|
auto it = m_buffer_map.find(buffer);
|
||||||
|
@ -196,10 +196,10 @@ private:
|
||||||
std::vector<T> m_buffers;
|
std::vector<T> m_buffers;
|
||||||
std::unordered_map<T, size_t> m_buffer_map;
|
std::unordered_map<T, size_t> m_buffer_map;
|
||||||
|
|
||||||
std::condition_variable m_cv;
|
boost::condition_variable m_cv;
|
||||||
std::vector<bool> m_open_slot;
|
std::vector<bool> m_open_slot;
|
||||||
size_t m_count;
|
size_t m_count;
|
||||||
std::mutex m_lock;
|
boost::mutex m_lock;
|
||||||
|
|
||||||
size_t m_buffer_count;
|
size_t m_buffer_count;
|
||||||
};
|
};
|
||||||
|
|
|
@ -150,8 +150,8 @@ namespace tools
|
||||||
/*! \brief calles m_handler */
|
/*! \brief calles m_handler */
|
||||||
static void handle_signal(int type)
|
static void handle_signal(int type)
|
||||||
{
|
{
|
||||||
static std::mutex m_mutex;
|
static boost::mutex m_mutex;
|
||||||
std::unique_lock<std::mutex> lock(m_mutex);
|
boost::unique_lock<boost::mutex> lock(m_mutex);
|
||||||
m_handler(type);
|
m_handler(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,4 +42,5 @@ target_link_libraries(connectivity_tool
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
||||||
${Boost_REGEX_LIBRARY}
|
${Boost_REGEX_LIBRARY}
|
||||||
|
${Boost_CHRONO_LIBRARY}
|
||||||
${Boost_SYSTEM_LIBRARY})
|
${Boost_SYSTEM_LIBRARY})
|
||||||
|
|
|
@ -34,7 +34,8 @@
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <boost/thread/mutex.hpp>
|
||||||
|
#include <boost/thread/lock_guard.hpp>
|
||||||
|
|
||||||
#include "common/varint.h"
|
#include "common/varint.h"
|
||||||
#include "warnings.h"
|
#include "warnings.h"
|
||||||
|
@ -52,8 +53,6 @@ namespace crypto {
|
||||||
using std::abort;
|
using std::abort;
|
||||||
using std::int32_t;
|
using std::int32_t;
|
||||||
using std::int64_t;
|
using std::int64_t;
|
||||||
using std::lock_guard;
|
|
||||||
using std::mutex;
|
|
||||||
using std::size_t;
|
using std::size_t;
|
||||||
using std::uint32_t;
|
using std::uint32_t;
|
||||||
using std::uint64_t;
|
using std::uint64_t;
|
||||||
|
@ -63,7 +62,7 @@ namespace crypto {
|
||||||
#include "random.h"
|
#include "random.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex random_lock;
|
boost::mutex random_lock;
|
||||||
|
|
||||||
static inline unsigned char *operator &(ec_point &point) {
|
static inline unsigned char *operator &(ec_point &point) {
|
||||||
return &reinterpret_cast<unsigned char &>(point);
|
return &reinterpret_cast<unsigned char &>(point);
|
||||||
|
@ -100,7 +99,7 @@ namespace crypto {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
secret_key crypto_ops::generate_keys(public_key &pub, secret_key &sec, const secret_key& recovery_key, bool recover) {
|
secret_key crypto_ops::generate_keys(public_key &pub, secret_key &sec, const secret_key& recovery_key, bool recover) {
|
||||||
lock_guard<mutex> lock(random_lock);
|
boost::lock_guard<boost::mutex> lock(random_lock);
|
||||||
ge_p3 point;
|
ge_p3 point;
|
||||||
|
|
||||||
secret_key rng;
|
secret_key rng;
|
||||||
|
@ -199,7 +198,7 @@ namespace crypto {
|
||||||
};
|
};
|
||||||
|
|
||||||
void crypto_ops::generate_signature(const hash &prefix_hash, const public_key &pub, const secret_key &sec, signature &sig) {
|
void crypto_ops::generate_signature(const hash &prefix_hash, const public_key &pub, const secret_key &sec, signature &sig) {
|
||||||
lock_guard<mutex> lock(random_lock);
|
boost::lock_guard<boost::mutex> lock(random_lock);
|
||||||
ge_p3 tmp3;
|
ge_p3 tmp3;
|
||||||
ec_scalar k;
|
ec_scalar k;
|
||||||
s_comm buf;
|
s_comm buf;
|
||||||
|
@ -280,7 +279,7 @@ POP_WARNINGS
|
||||||
const public_key *const *pubs, size_t pubs_count,
|
const public_key *const *pubs, size_t pubs_count,
|
||||||
const secret_key &sec, size_t sec_index,
|
const secret_key &sec, size_t sec_index,
|
||||||
signature *sig) {
|
signature *sig) {
|
||||||
lock_guard<mutex> lock(random_lock);
|
boost::lock_guard<boost::mutex> lock(random_lock);
|
||||||
size_t i;
|
size_t i;
|
||||||
ge_p3 image_unp;
|
ge_p3 image_unp;
|
||||||
ge_dsmp image_pre;
|
ge_dsmp image_pre;
|
||||||
|
|
|
@ -31,7 +31,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <mutex>
|
#include <boost/thread/mutex.hpp>
|
||||||
|
#include <boost/thread/lock_guard.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "common/pod-class.h"
|
#include "common/pod-class.h"
|
||||||
|
@ -44,7 +45,7 @@ namespace crypto {
|
||||||
#include "random.h"
|
#include "random.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
extern std::mutex random_lock;
|
extern boost::mutex random_lock;
|
||||||
|
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
POD_CLASS ec_point {
|
POD_CLASS ec_point {
|
||||||
|
@ -121,7 +122,7 @@ namespace crypto {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
typename std::enable_if<std::is_pod<T>::value, T>::type rand() {
|
typename std::enable_if<std::is_pod<T>::value, T>::type rand() {
|
||||||
typename std::remove_cv<T>::type res;
|
typename std::remove_cv<T>::type res;
|
||||||
std::lock_guard<std::mutex> lock(random_lock);
|
boost::lock_guard<boost::mutex> lock(random_lock);
|
||||||
generate_random_bytes(sizeof(T), &res);
|
generate_random_bytes(sizeof(T), &res);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2105,7 +2105,7 @@ bool Blockchain::check_tx_inputs(const transaction& tx, uint64_t* pmax_used_bloc
|
||||||
std::vector < uint64_t > results;
|
std::vector < uint64_t > results;
|
||||||
results.resize(tx.vin.size(), 0);
|
results.resize(tx.vin.size(), 0);
|
||||||
|
|
||||||
int threads = std::thread::hardware_concurrency();
|
int threads = boost::thread::hardware_concurrency();
|
||||||
|
|
||||||
boost::asio::io_service ioservice;
|
boost::asio::io_service ioservice;
|
||||||
boost::thread_group threadpool;
|
boost::thread_group threadpool;
|
||||||
|
@ -2965,7 +2965,7 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::list<block_complete_e
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
bool blocks_exist = false;
|
bool blocks_exist = false;
|
||||||
uint64_t threads = std::thread::hardware_concurrency();
|
uint64_t threads = boost::thread::hardware_concurrency();
|
||||||
|
|
||||||
if (blocks_entry.size() > 1 && threads > 1 && m_max_prepare_blocks_threads > 1)
|
if (blocks_entry.size() > 1 && threads > 1 && m_max_prepare_blocks_threads > 1)
|
||||||
{
|
{
|
||||||
|
@ -3165,7 +3165,7 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::list<block_complete_e
|
||||||
// [output] stores all transactions for each tx_out_index::hash found
|
// [output] stores all transactions for each tx_out_index::hash found
|
||||||
std::vector<std::unordered_map<crypto::hash, cryptonote::transaction>> transactions(amounts.size());
|
std::vector<std::unordered_map<crypto::hash, cryptonote::transaction>> transactions(amounts.size());
|
||||||
|
|
||||||
threads = std::thread::hardware_concurrency();
|
threads = boost::thread::hardware_concurrency();
|
||||||
if (!m_db->can_thread_bulk_indices())
|
if (!m_db->can_thread_bulk_indices())
|
||||||
threads = 1;
|
threads = 1;
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ namespace cryptonote
|
||||||
bool m_one_request = true;
|
bool m_one_request = true;
|
||||||
|
|
||||||
// static std::ofstream m_logreq;
|
// static std::ofstream m_logreq;
|
||||||
std::mutex m_buffer_mutex;
|
boost::mutex m_buffer_mutex;
|
||||||
double get_avg_block_size();
|
double get_avg_block_size();
|
||||||
boost::circular_buffer<size_t> m_avg_buffer = boost::circular_buffer<size_t>(10);
|
boost::circular_buffer<size_t> m_avg_buffer = boost::circular_buffer<size_t>(10);
|
||||||
|
|
||||||
|
|
|
@ -99,8 +99,8 @@ namespace {
|
||||||
// to allow the user to read any output.
|
// to allow the user to read any output.
|
||||||
void pause_to_display_admin_window_messages()
|
void pause_to_display_admin_window_messages()
|
||||||
{
|
{
|
||||||
std::chrono::milliseconds how_long{1500};
|
boost::chrono::milliseconds how_long{1500};
|
||||||
std::this_thread::sleep_for(how_long);
|
boost::this_thread::sleep_for(how_long);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,7 +56,7 @@ namespace windows {
|
||||||
private:
|
private:
|
||||||
SERVICE_STATUS_HANDLE m_status_handle{nullptr};
|
SERVICE_STATUS_HANDLE m_status_handle{nullptr};
|
||||||
SERVICE_STATUS m_status{};
|
SERVICE_STATUS m_status{};
|
||||||
std::mutex m_lock{};
|
boost::mutex m_lock{};
|
||||||
std::string m_name;
|
std::string m_name;
|
||||||
T_handler m_handler;
|
T_handler m_handler;
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ target_link_libraries(simpleminer
|
||||||
${Boost_FILESYSTEM_LIBRARY}
|
${Boost_FILESYSTEM_LIBRARY}
|
||||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
||||||
${Boost_REGEX_LIBRARY}
|
${Boost_REGEX_LIBRARY}
|
||||||
|
${Boost_CHRONO_LIBRARY}
|
||||||
${Boost_SYSTEM_LIBRARY}
|
${Boost_SYSTEM_LIBRARY}
|
||||||
${Boost_THREAD_LIBRARY}
|
${Boost_THREAD_LIBRARY}
|
||||||
${CMAKE_THREAD_LIBS_INIT}
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace epee
|
||||||
namespace net_utils
|
namespace net_utils
|
||||||
{
|
{
|
||||||
data_logger &data_logger::get_instance() {
|
data_logger &data_logger::get_instance() {
|
||||||
std::call_once(m_singleton,
|
boost::call_once(m_singleton,
|
||||||
[] {
|
[] {
|
||||||
_info_c("dbg/data","Creating singleton of data_logger");
|
_info_c("dbg/data","Creating singleton of data_logger");
|
||||||
if (m_state != data_logger_state::state_before_init) { _erro_c("dbg/data","Internal error in singleton"); throw std::runtime_error("data_logger singleton"); }
|
if (m_state != data_logger_state::state_before_init) { _erro_c("dbg/data","Internal error in singleton"); throw std::runtime_error("data_logger singleton"); }
|
||||||
|
@ -61,7 +61,7 @@ namespace net_utils
|
||||||
data_logger::data_logger() {
|
data_logger::data_logger() {
|
||||||
_note_c("dbg/data","Starting data logger (for graphs data)");
|
_note_c("dbg/data","Starting data logger (for graphs data)");
|
||||||
if (m_state != data_logger_state::state_during_init) { _erro_c("dbg/data","Singleton ctor state"); throw std::runtime_error("data_logger ctor state"); }
|
if (m_state != data_logger_state::state_during_init) { _erro_c("dbg/data","Singleton ctor state"); throw std::runtime_error("data_logger ctor state"); }
|
||||||
std::lock_guard<std::mutex> lock(mMutex); // lock
|
boost::lock_guard<boost::mutex> lock(mMutex); // lock
|
||||||
|
|
||||||
// prepare all the files for given data channels:
|
// prepare all the files for given data channels:
|
||||||
mFilesMap["peers"] = data_logger::fileData("log/dr-monero/peers.data");
|
mFilesMap["peers"] = data_logger::fileData("log/dr-monero/peers.data");
|
||||||
|
@ -89,11 +89,11 @@ namespace net_utils
|
||||||
std::shared_ptr<boost::thread> logger_thread(new boost::thread([&]() {
|
std::shared_ptr<boost::thread> logger_thread(new boost::thread([&]() {
|
||||||
_info_c("dbg/data","Inside thread for data logger");
|
_info_c("dbg/data","Inside thread for data logger");
|
||||||
while (m_state == data_logger_state::state_during_init) { // wait for creation to be done (in other thread, in singleton) before actually running
|
while (m_state == data_logger_state::state_during_init) { // wait for creation to be done (in other thread, in singleton) before actually running
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
boost::this_thread::sleep_for(boost::chrono::seconds(1));
|
||||||
}
|
}
|
||||||
_info_c("dbg/data","Inside thread for data logger - going into main loop");
|
_info_c("dbg/data","Inside thread for data logger - going into main loop");
|
||||||
while (m_state == data_logger_state::state_ready_to_use) { // run as long as we are not closing the single object
|
while (m_state == data_logger_state::state_ready_to_use) { // run as long as we are not closing the single object
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
boost::this_thread::sleep_for(boost::chrono::seconds(1));
|
||||||
saveToFile(); // save all the pending data
|
saveToFile(); // save all the pending data
|
||||||
}
|
}
|
||||||
_info_c("dbg/data","Inside thread for data logger - done the main loop");
|
_info_c("dbg/data","Inside thread for data logger - done the main loop");
|
||||||
|
@ -106,12 +106,12 @@ namespace net_utils
|
||||||
data_logger::~data_logger() {
|
data_logger::~data_logger() {
|
||||||
_note_c("dbg/data","Destructor of the data logger");
|
_note_c("dbg/data","Destructor of the data logger");
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(mMutex);
|
boost::lock_guard<boost::mutex> lock(mMutex);
|
||||||
m_state = data_logger_state::state_dying;
|
m_state = data_logger_state::state_dying;
|
||||||
}
|
}
|
||||||
_info_c("dbg/data","State was set to dying");
|
_info_c("dbg/data","State was set to dying");
|
||||||
while(m_thread_maybe_running) { // wait for the thread to exit
|
while(m_thread_maybe_running) { // wait for the thread to exit
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
boost::this_thread::sleep_for(boost::chrono::seconds(1));
|
||||||
_info_c("dbg/data","Waiting for background thread to exit");
|
_info_c("dbg/data","Waiting for background thread to exit");
|
||||||
}
|
}
|
||||||
_info_c("dbg/data","Thread exited");
|
_info_c("dbg/data","Thread exited");
|
||||||
|
@ -123,7 +123,7 @@ namespace net_utils
|
||||||
}
|
}
|
||||||
|
|
||||||
void data_logger::add_data(std::string filename, unsigned int data) {
|
void data_logger::add_data(std::string filename, unsigned int data) {
|
||||||
std::lock_guard<std::mutex> lock(mMutex);
|
boost::lock_guard<boost::mutex> lock(mMutex);
|
||||||
if (m_state != data_logger_state::state_ready_to_use) { _info_c("dbg/data","Data logger is not ready, returning."); return; }
|
if (m_state != data_logger_state::state_ready_to_use) { _info_c("dbg/data","Data logger is not ready, returning."); return; }
|
||||||
|
|
||||||
if (mFilesMap.find(filename) == mFilesMap.end()) { // no such file/counter
|
if (mFilesMap.find(filename) == mFilesMap.end()) { // no such file/counter
|
||||||
|
@ -151,7 +151,7 @@ namespace net_utils
|
||||||
|
|
||||||
void data_logger::saveToFile() {
|
void data_logger::saveToFile() {
|
||||||
_dbg2_c("dbg/data","saving to files");
|
_dbg2_c("dbg/data","saving to files");
|
||||||
std::lock_guard<std::mutex> lock(mMutex);
|
boost::lock_guard<boost::mutex> lock(mMutex);
|
||||||
if (m_state != data_logger_state::state_ready_to_use) { _info_c("dbg/data","Data logger is not ready, returning."); return; }
|
if (m_state != data_logger_state::state_ready_to_use) { _info_c("dbg/data","Data logger is not ready, returning."); return; }
|
||||||
nOT::nUtils::cFilesystemUtils::CreateDirTree("log/dr-monero/net/");
|
nOT::nUtils::cFilesystemUtils::CreateDirTree("log/dr-monero/net/");
|
||||||
for (auto &element : mFilesMap)
|
for (auto &element : mFilesMap)
|
||||||
|
@ -194,7 +194,7 @@ namespace net_utils
|
||||||
data_logger_state data_logger::m_state(data_logger_state::state_before_init); ///< (static) state of the singleton object
|
data_logger_state data_logger::m_state(data_logger_state::state_before_init); ///< (static) state of the singleton object
|
||||||
std::atomic<bool> data_logger::m_save_graph(false); // (static)
|
std::atomic<bool> data_logger::m_save_graph(false); // (static)
|
||||||
std::atomic<bool> data_logger::m_thread_maybe_running(false); // (static)
|
std::atomic<bool> data_logger::m_thread_maybe_running(false); // (static)
|
||||||
std::once_flag data_logger::m_singleton; // (static)
|
boost::once_flag data_logger::m_singleton; // (static)
|
||||||
std::unique_ptr<data_logger> data_logger::m_obj; // (static)
|
std::unique_ptr<data_logger> data_logger::m_obj; // (static)
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -33,8 +33,9 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <thread>
|
#include <boost/thread/thread.hpp>
|
||||||
#include <mutex>
|
#include <boost/thread/mutex.hpp>
|
||||||
|
#include <boost/thread/once.hpp>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
|
|
||||||
namespace epee
|
namespace epee
|
||||||
|
@ -71,7 +72,7 @@ enum class data_logger_state { state_before_init, state_during_init, state_ready
|
||||||
static bool is_dying();
|
static bool is_dying();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::once_flag m_singleton; ///< to guarantee singleton creates the object exactly once
|
static boost::once_flag m_singleton; ///< to guarantee singleton creates the object exactly once
|
||||||
static data_logger_state m_state; ///< state of the singleton object
|
static data_logger_state m_state; ///< state of the singleton object
|
||||||
static std::atomic<bool> m_thread_maybe_running; ///< is the background thread (more or less) running, or is it fully finished
|
static std::atomic<bool> m_thread_maybe_running; ///< is the background thread (more or less) running, or is it fully finished
|
||||||
static std::unique_ptr<data_logger> m_obj; ///< the singleton object. Only use it via get_instance(). Can be killed by kill_instance()
|
static std::unique_ptr<data_logger> m_obj; ///< the singleton object. Only use it via get_instance(). Can be killed by kill_instance()
|
||||||
|
@ -94,7 +95,7 @@ enum class data_logger_state { state_before_init, state_during_init, state_ready
|
||||||
};
|
};
|
||||||
|
|
||||||
std::map<std::string, fileData> mFilesMap;
|
std::map<std::string, fileData> mFilesMap;
|
||||||
std::mutex mMutex;
|
boost::mutex mMutex;
|
||||||
void saveToFile(); ///< write data to the target files. do not use this directly
|
void saveToFile(); ///< write data to the target files. do not use this directly
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -585,7 +585,7 @@ namespace nodetool
|
||||||
break;
|
break;
|
||||||
epee::net_utils::data_logger::get_instance().add_data("peers", number_of_peers);
|
epee::net_utils::data_logger::get_instance().add_data("peers", number_of_peers);
|
||||||
|
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
boost::this_thread::sleep_for(boost::chrono::seconds(1));
|
||||||
} // main loop of thread
|
} // main loop of thread
|
||||||
_note("Thread monitor number of peers - done");
|
_note("Thread monitor number of peers - done");
|
||||||
})); // lambda
|
})); // lambda
|
||||||
|
|
|
@ -243,7 +243,7 @@ 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) {
|
void network_throttle::logger_handle_net(const std::string &filename, double time, size_t size) {
|
||||||
if (! epee::net_utils::data_logger::m_save_graph)
|
if (! epee::net_utils::data_logger::m_save_graph)
|
||||||
return;
|
return;
|
||||||
std::mutex mutex;
|
boost::mutex mutex;
|
||||||
mutex.lock(); {
|
mutex.lock(); {
|
||||||
std::fstream file;
|
std::fstream file;
|
||||||
file.open(filename.c_str(), std::ios::app | std::ios::out );
|
file.open(filename.c_str(), std::ios::app | std::ios::out );
|
||||||
|
|
|
@ -67,9 +67,9 @@ namespace net_utils
|
||||||
|
|
||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
// static:
|
// static:
|
||||||
std::mutex network_throttle_manager::m_lock_get_global_throttle_in;
|
boost::mutex network_throttle_manager::m_lock_get_global_throttle_in;
|
||||||
std::mutex network_throttle_manager::m_lock_get_global_throttle_inreq;
|
boost::mutex network_throttle_manager::m_lock_get_global_throttle_inreq;
|
||||||
std::mutex network_throttle_manager::m_lock_get_global_throttle_out;
|
boost::mutex network_throttle_manager::m_lock_get_global_throttle_out;
|
||||||
|
|
||||||
int network_throttle_manager::xxx;
|
int network_throttle_manager::xxx;
|
||||||
|
|
||||||
|
@ -77,27 +77,27 @@ int network_throttle_manager::xxx;
|
||||||
// ================================================================================================
|
// ================================================================================================
|
||||||
// methods:
|
// methods:
|
||||||
i_network_throttle & network_throttle_manager::get_global_throttle_in() {
|
i_network_throttle & network_throttle_manager::get_global_throttle_in() {
|
||||||
std::call_once(m_once_get_global_throttle_in, [] { m_obj_get_global_throttle_in.reset(new network_throttle("in/all","<<< global-IN",10)); } );
|
boost::call_once(m_once_get_global_throttle_in, [] { m_obj_get_global_throttle_in.reset(new network_throttle("in/all","<<< global-IN",10)); } );
|
||||||
return * m_obj_get_global_throttle_in;
|
return * m_obj_get_global_throttle_in;
|
||||||
}
|
}
|
||||||
std::once_flag network_throttle_manager::m_once_get_global_throttle_in;
|
boost::once_flag network_throttle_manager::m_once_get_global_throttle_in;
|
||||||
std::unique_ptr<i_network_throttle> network_throttle_manager::m_obj_get_global_throttle_in;
|
std::unique_ptr<i_network_throttle> network_throttle_manager::m_obj_get_global_throttle_in;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
i_network_throttle & network_throttle_manager::get_global_throttle_inreq() {
|
i_network_throttle & network_throttle_manager::get_global_throttle_inreq() {
|
||||||
std::call_once(m_once_get_global_throttle_inreq, [] { m_obj_get_global_throttle_inreq.reset(new network_throttle("inreq/all", "<== global-IN-REQ",10)); } );
|
boost::call_once(m_once_get_global_throttle_inreq, [] { m_obj_get_global_throttle_inreq.reset(new network_throttle("inreq/all", "<== global-IN-REQ",10)); } );
|
||||||
return * m_obj_get_global_throttle_inreq;
|
return * m_obj_get_global_throttle_inreq;
|
||||||
}
|
}
|
||||||
std::once_flag network_throttle_manager::m_once_get_global_throttle_inreq;
|
boost::once_flag network_throttle_manager::m_once_get_global_throttle_inreq;
|
||||||
std::unique_ptr<i_network_throttle> network_throttle_manager::m_obj_get_global_throttle_inreq;
|
std::unique_ptr<i_network_throttle> network_throttle_manager::m_obj_get_global_throttle_inreq;
|
||||||
|
|
||||||
|
|
||||||
i_network_throttle & network_throttle_manager::get_global_throttle_out() {
|
i_network_throttle & network_throttle_manager::get_global_throttle_out() {
|
||||||
std::call_once(m_once_get_global_throttle_out, [] { m_obj_get_global_throttle_out.reset(new network_throttle("out/all", ">>> global-OUT",10)); } );
|
boost::call_once(m_once_get_global_throttle_out, [] { m_obj_get_global_throttle_out.reset(new network_throttle("out/all", ">>> global-OUT",10)); } );
|
||||||
return * m_obj_get_global_throttle_out;
|
return * m_obj_get_global_throttle_out;
|
||||||
}
|
}
|
||||||
std::once_flag network_throttle_manager::m_once_get_global_throttle_out;
|
boost::once_flag network_throttle_manager::m_once_get_global_throttle_out;
|
||||||
std::unique_ptr<i_network_throttle> network_throttle_manager::m_obj_get_global_throttle_out;
|
std::unique_ptr<i_network_throttle> network_throttle_manager::m_obj_get_global_throttle_out;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -113,16 +113,16 @@ class network_throttle_manager {
|
||||||
//protected:
|
//protected:
|
||||||
public: // XXX
|
public: // XXX
|
||||||
// [[note1]]
|
// [[note1]]
|
||||||
static std::once_flag m_once_get_global_throttle_in;
|
static boost::once_flag m_once_get_global_throttle_in;
|
||||||
static std::once_flag m_once_get_global_throttle_inreq; // [[note2]]
|
static boost::once_flag m_once_get_global_throttle_inreq; // [[note2]]
|
||||||
static std::once_flag m_once_get_global_throttle_out;
|
static boost::once_flag m_once_get_global_throttle_out;
|
||||||
static std::unique_ptr<i_network_throttle> m_obj_get_global_throttle_in;
|
static std::unique_ptr<i_network_throttle> m_obj_get_global_throttle_in;
|
||||||
static std::unique_ptr<i_network_throttle> m_obj_get_global_throttle_inreq;
|
static std::unique_ptr<i_network_throttle> m_obj_get_global_throttle_inreq;
|
||||||
static std::unique_ptr<i_network_throttle> m_obj_get_global_throttle_out;
|
static std::unique_ptr<i_network_throttle> m_obj_get_global_throttle_out;
|
||||||
|
|
||||||
static std::mutex m_lock_get_global_throttle_in;
|
static boost::mutex m_lock_get_global_throttle_in;
|
||||||
static std::mutex m_lock_get_global_throttle_inreq;
|
static boost::mutex m_lock_get_global_throttle_inreq;
|
||||||
static std::mutex m_lock_get_global_throttle_out;
|
static boost::mutex m_lock_get_global_throttle_out;
|
||||||
|
|
||||||
friend class cryptonote::cryptonote_protocol_handler_base; // FRIEND - to directly access global throttle-s. !! REMEMBER TO USE LOCKS!
|
friend class cryptonote::cryptonote_protocol_handler_base; // FRIEND - to directly access global throttle-s. !! REMEMBER TO USE LOCKS!
|
||||||
friend class connection_basic; // FRIEND - to directly access global throttle-s. !! REMEMBER TO USE LOCKS!
|
friend class connection_basic; // FRIEND - to directly access global throttle-s. !! REMEMBER TO USE LOCKS!
|
||||||
|
|
|
@ -445,7 +445,7 @@ bool simple_wallet::set_auto_refresh(const std::vector<std::string> &args/* = st
|
||||||
if (auto_refresh && !m_auto_refresh_run.load(std::memory_order_relaxed))
|
if (auto_refresh && !m_auto_refresh_run.load(std::memory_order_relaxed))
|
||||||
{
|
{
|
||||||
m_auto_refresh_run.store(true, std::memory_order_relaxed);
|
m_auto_refresh_run.store(true, std::memory_order_relaxed);
|
||||||
m_auto_refresh_thread = std::thread([&]{wallet_refresh_thread();});
|
m_auto_refresh_thread = boost::thread([&]{wallet_refresh_thread();});
|
||||||
}
|
}
|
||||||
else if (!auto_refresh && m_auto_refresh_run.load(std::memory_order_relaxed))
|
else if (!auto_refresh && m_auto_refresh_run.load(std::memory_order_relaxed))
|
||||||
{
|
{
|
||||||
|
@ -1256,7 +1256,7 @@ bool simple_wallet::close_wallet()
|
||||||
m_auto_refresh_run.store(false, std::memory_order_relaxed);
|
m_auto_refresh_run.store(false, std::memory_order_relaxed);
|
||||||
m_wallet->stop();
|
m_wallet->stop();
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(m_auto_refresh_mutex);
|
boost::unique_lock<boost::mutex> lock(m_auto_refresh_mutex);
|
||||||
m_auto_refresh_cond.notify_one();
|
m_auto_refresh_cond.notify_one();
|
||||||
}
|
}
|
||||||
m_auto_refresh_thread.join();
|
m_auto_refresh_thread.join();
|
||||||
|
@ -1341,7 +1341,7 @@ bool simple_wallet::start_mining(const std::vector<std::string>& args)
|
||||||
req.miner_address = m_wallet->get_account().get_public_address_str(m_wallet->testnet());
|
req.miner_address = m_wallet->get_account().get_public_address_str(m_wallet->testnet());
|
||||||
|
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
size_t max_mining_threads_count = (std::max)(std::thread::hardware_concurrency(), static_cast<unsigned>(2));
|
size_t max_mining_threads_count = (std::max)(boost::thread::hardware_concurrency(), static_cast<unsigned>(2));
|
||||||
if (0 == args.size())
|
if (0 == args.size())
|
||||||
{
|
{
|
||||||
req.threads_count = 1;
|
req.threads_count = 1;
|
||||||
|
@ -1458,7 +1458,7 @@ bool simple_wallet::refresh_main(uint64_t start_height, bool reset)
|
||||||
m_auto_refresh_run.store(false, std::memory_order_relaxed);
|
m_auto_refresh_run.store(false, std::memory_order_relaxed);
|
||||||
// stop any background refresh, and take over
|
// stop any background refresh, and take over
|
||||||
m_wallet->stop();
|
m_wallet->stop();
|
||||||
std::unique_lock<std::mutex> lock(m_auto_refresh_mutex);
|
boost::unique_lock<boost::mutex> lock(m_auto_refresh_mutex);
|
||||||
m_auto_refresh_cond.notify_one();
|
m_auto_refresh_cond.notify_one();
|
||||||
|
|
||||||
if (reset)
|
if (reset)
|
||||||
|
@ -2434,7 +2434,7 @@ void simple_wallet::wallet_refresh_thread()
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(m_auto_refresh_mutex);
|
boost::unique_lock<boost::mutex> lock(m_auto_refresh_mutex);
|
||||||
if (!m_auto_refresh_run.load(std::memory_order_relaxed))
|
if (!m_auto_refresh_run.load(std::memory_order_relaxed))
|
||||||
break;
|
break;
|
||||||
m_auto_refresh_refreshing = true;
|
m_auto_refresh_refreshing = true;
|
||||||
|
@ -2447,7 +2447,7 @@ void simple_wallet::wallet_refresh_thread()
|
||||||
m_auto_refresh_refreshing = false;
|
m_auto_refresh_refreshing = false;
|
||||||
if (!m_auto_refresh_run.load(std::memory_order_relaxed))
|
if (!m_auto_refresh_run.load(std::memory_order_relaxed))
|
||||||
break;
|
break;
|
||||||
m_auto_refresh_cond.wait_for(lock, chrono::seconds(90));
|
m_auto_refresh_cond.wait_for(lock, boost::chrono::seconds(90));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
|
@ -2457,7 +2457,7 @@ bool simple_wallet::run()
|
||||||
m_auto_refresh_run = m_wallet->auto_refresh();
|
m_auto_refresh_run = m_wallet->auto_refresh();
|
||||||
if (m_auto_refresh_run)
|
if (m_auto_refresh_run)
|
||||||
{
|
{
|
||||||
m_auto_refresh_thread = std::thread([&]{wallet_refresh_thread();});
|
m_auto_refresh_thread = boost::thread([&]{wallet_refresh_thread();});
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -242,9 +242,9 @@ namespace cryptonote
|
||||||
|
|
||||||
std::atomic<bool> m_auto_refresh_run;
|
std::atomic<bool> m_auto_refresh_run;
|
||||||
bool m_auto_refresh_refreshing;
|
bool m_auto_refresh_refreshing;
|
||||||
std::thread m_auto_refresh_thread;
|
boost::thread m_auto_refresh_thread;
|
||||||
std::mutex m_auto_refresh_mutex;
|
boost::mutex m_auto_refresh_mutex;
|
||||||
std::condition_variable m_auto_refresh_cond;
|
boost::condition_variable m_auto_refresh_cond;
|
||||||
std::atomic<bool> m_in_manual_refresh;
|
std::atomic<bool> m_in_manual_refresh;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -204,7 +204,7 @@ void wallet2::process_new_transaction(const cryptonote::transaction& tx, uint64_
|
||||||
|
|
||||||
tx_pub_key = pub_key_field.pub_key;
|
tx_pub_key = pub_key_field.pub_key;
|
||||||
bool r = true;
|
bool r = true;
|
||||||
int threads = std::thread::hardware_concurrency();
|
int threads = boost::thread::hardware_concurrency();
|
||||||
if (miner_tx && m_refresh_type == RefreshNoCoinbase)
|
if (miner_tx && m_refresh_type == RefreshNoCoinbase)
|
||||||
{
|
{
|
||||||
// assume coinbase isn't for us
|
// assume coinbase isn't for us
|
||||||
|
@ -574,7 +574,7 @@ void wallet2::process_blocks(uint64_t start_height, const std::list<cryptonote::
|
||||||
size_t current_index = start_height;
|
size_t current_index = start_height;
|
||||||
blocks_added = 0;
|
blocks_added = 0;
|
||||||
|
|
||||||
int threads = std::thread::hardware_concurrency();
|
int threads = boost::thread::hardware_concurrency();
|
||||||
if (threads > 1)
|
if (threads > 1)
|
||||||
{
|
{
|
||||||
std::vector<crypto::hash> round_block_hashes(threads);
|
std::vector<crypto::hash> round_block_hashes(threads);
|
||||||
|
@ -771,7 +771,7 @@ void wallet2::refresh(uint64_t start_height, uint64_t & blocks_fetched, bool& re
|
||||||
size_t try_count = 0;
|
size_t try_count = 0;
|
||||||
crypto::hash last_tx_hash_id = m_transfers.size() ? get_transaction_hash(m_transfers.back().m_tx) : null_hash;
|
crypto::hash last_tx_hash_id = m_transfers.size() ? get_transaction_hash(m_transfers.back().m_tx) : null_hash;
|
||||||
std::list<crypto::hash> short_chain_history;
|
std::list<crypto::hash> short_chain_history;
|
||||||
std::thread pull_thread;
|
boost::thread pull_thread;
|
||||||
uint64_t blocks_start_height;
|
uint64_t blocks_start_height;
|
||||||
std::list<cryptonote::block_complete_entry> blocks;
|
std::list<cryptonote::block_complete_entry> blocks;
|
||||||
|
|
||||||
|
@ -788,7 +788,7 @@ void wallet2::refresh(uint64_t start_height, uint64_t & blocks_fetched, bool& re
|
||||||
uint64_t next_blocks_start_height;
|
uint64_t next_blocks_start_height;
|
||||||
std::list<cryptonote::block_complete_entry> next_blocks;
|
std::list<cryptonote::block_complete_entry> next_blocks;
|
||||||
bool error = false;
|
bool error = false;
|
||||||
pull_thread = std::thread([&]{pull_next_blocks(start_height, next_blocks_start_height, short_chain_history, blocks, next_blocks, error);});
|
pull_thread = boost::thread([&]{pull_next_blocks(start_height, next_blocks_start_height, short_chain_history, blocks, next_blocks, error);});
|
||||||
|
|
||||||
process_blocks(blocks_start_height, blocks, added_blocks);
|
process_blocks(blocks_start_height, blocks, added_blocks);
|
||||||
blocks_fetched += added_blocks;
|
blocks_fetched += added_blocks;
|
||||||
|
@ -1312,7 +1312,7 @@ bool wallet2::prepare_file_names(const std::string& file_path)
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
bool wallet2::check_connection()
|
bool wallet2::check_connection()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(m_daemon_rpc_mutex);
|
boost::lock_guard<boost::mutex> lock(m_daemon_rpc_mutex);
|
||||||
|
|
||||||
if(m_http_client.is_connected())
|
if(m_http_client.is_connected())
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -407,7 +407,7 @@ namespace tools
|
||||||
|
|
||||||
std::atomic<bool> m_run;
|
std::atomic<bool> m_run;
|
||||||
|
|
||||||
std::mutex m_daemon_rpc_mutex;
|
boost::mutex m_daemon_rpc_mutex;
|
||||||
|
|
||||||
i_wallet2_callback* m_callback;
|
i_wallet2_callback* m_callback;
|
||||||
bool m_testnet;
|
bool m_testnet;
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <system_error>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue