diff options
author | Riccardo Spagni <ric@spagni.net> | 2016-03-11 20:15:10 +0200 |
---|---|---|
committer | Riccardo Spagni <ric@spagni.net> | 2016-03-11 20:15:10 +0200 |
commit | dfd0e9c97d80c5cd7115d6cbb49cce08168071b6 (patch) | |
tree | 7bb5c56c18c83f3180101e310198cb3e3fdf1ab7 /src | |
parent | Merge pull request #711 (diff) | |
parent | Need to link boost::chrono in more places now (diff) | |
download | monero-dfd0e9c97d80c5cd7115d6cbb49cce08168071b6.tar.xz |
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)
Diffstat (limited to 'src')
-rw-r--r-- | src/blockchain_db/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/blockchain_db/berkeleydb/db_bdb.cpp | 2 | ||||
-rw-r--r-- | src/blockchain_db/berkeleydb/db_bdb.h | 8 | ||||
-rw-r--r-- | src/common/util.h | 4 | ||||
-rw-r--r-- | src/connectivity_tool/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/crypto/crypto.cpp | 13 | ||||
-rw-r--r-- | src/crypto/crypto.h | 7 | ||||
-rw-r--r-- | src/cryptonote_core/blockchain.cpp | 6 | ||||
-rw-r--r-- | src/cryptonote_protocol/cryptonote_protocol_handler.h | 2 | ||||
-rw-r--r-- | src/daemonizer/windows_service.cpp | 4 | ||||
-rw-r--r-- | src/daemonizer/windows_service_runner.h | 2 | ||||
-rw-r--r-- | src/miner/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/p2p/data_logger.cpp | 18 | ||||
-rw-r--r-- | src/p2p/data_logger.hpp | 9 | ||||
-rw-r--r-- | src/p2p/net_node.inl | 2 | ||||
-rw-r--r-- | src/p2p/network_throttle-detail.cpp | 2 | ||||
-rw-r--r-- | src/p2p/network_throttle.cpp | 18 | ||||
-rw-r--r-- | src/p2p/network_throttle.hpp | 12 | ||||
-rw-r--r-- | src/simplewallet/simplewallet.cpp | 14 | ||||
-rw-r--r-- | src/simplewallet/simplewallet.h | 6 | ||||
-rw-r--r-- | src/wallet/wallet2.cpp | 10 | ||||
-rw-r--r-- | src/wallet/wallet2.h | 2 | ||||
-rw-r--r-- | src/wallet/wallet_errors.h | 1 |
23 files changed, 75 insertions, 70 deletions
diff --git a/src/blockchain_db/CMakeLists.txt b/src/blockchain_db/CMakeLists.txt index 4953d92a6..39459d5c4 100644 --- a/src/blockchain_db/CMakeLists.txt +++ b/src/blockchain_db/CMakeLists.txt @@ -65,6 +65,7 @@ target_link_libraries(blockchain_db crypto cryptonote_core ${Boost_DATE_TIME_LIBRARY} + ${Boost_CHRONO_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_SERIALIZATION_LIBRARY} ${LMDB_LIBRARY} diff --git a/src/blockchain_db/berkeleydb/db_bdb.cpp b/src/blockchain_db/berkeleydb/db_bdb.cpp index bfdb22a10..1fef9e619 100644 --- a/src/blockchain_db/berkeleydb/db_bdb.cpp +++ b/src/blockchain_db/berkeleydb/db_bdb.cpp @@ -135,7 +135,7 @@ const unsigned int DB_BUFFER_LENGTH = 32 * MB; const unsigned int DB_DEF_CACHESIZE = 256 * MB; #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 const unsigned int DB_BUFFER_COUNT = 1; #endif diff --git a/src/blockchain_db/berkeleydb/db_bdb.h b/src/blockchain_db/berkeleydb/db_bdb.h index bf9665cae..d7cbd24e7 100644 --- a/src/blockchain_db/berkeleydb/db_bdb.h +++ b/src/blockchain_db/berkeleydb/db_bdb.h @@ -130,7 +130,7 @@ public: 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_count; @@ -154,7 +154,7 @@ public: void release_buffer(T buffer) { - std::unique_lock<std::mutex> lock(m_lock); + boost::unique_lock<boost::mutex> lock(m_lock); assert(buffer != nullptr); auto it = m_buffer_map.find(buffer); @@ -196,10 +196,10 @@ private: std::vector<T> m_buffers; 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; size_t m_count; - std::mutex m_lock; + boost::mutex m_lock; size_t m_buffer_count; }; diff --git a/src/common/util.h b/src/common/util.h index de0244c7f..7554b1df7 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -150,8 +150,8 @@ namespace tools /*! \brief calles m_handler */ static void handle_signal(int type) { - static std::mutex m_mutex; - std::unique_lock<std::mutex> lock(m_mutex); + static boost::mutex m_mutex; + boost::unique_lock<boost::mutex> lock(m_mutex); m_handler(type); } diff --git a/src/connectivity_tool/CMakeLists.txt b/src/connectivity_tool/CMakeLists.txt index 223d6e67f..0ade952d2 100644 --- a/src/connectivity_tool/CMakeLists.txt +++ b/src/connectivity_tool/CMakeLists.txt @@ -42,4 +42,5 @@ target_link_libraries(connectivity_tool ${CMAKE_THREAD_LIBS_INIT} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_REGEX_LIBRARY} + ${Boost_CHRONO_LIBRARY} ${Boost_SYSTEM_LIBRARY}) diff --git a/src/crypto/crypto.cpp b/src/crypto/crypto.cpp index fa7b1b580..e47aab0f7 100644 --- a/src/crypto/crypto.cpp +++ b/src/crypto/crypto.cpp @@ -34,7 +34,8 @@ #include <cstdlib> #include <cstring> #include <memory> -#include <mutex> +#include <boost/thread/mutex.hpp> +#include <boost/thread/lock_guard.hpp> #include "common/varint.h" #include "warnings.h" @@ -52,8 +53,6 @@ namespace crypto { using std::abort; using std::int32_t; using std::int64_t; - using std::lock_guard; - using std::mutex; using std::size_t; using std::uint32_t; using std::uint64_t; @@ -63,7 +62,7 @@ namespace crypto { #include "random.h" } - mutex random_lock; + boost::mutex random_lock; static inline unsigned char *operator &(ec_point &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) { - lock_guard<mutex> lock(random_lock); + boost::lock_guard<boost::mutex> lock(random_lock); ge_p3 point; 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) { - lock_guard<mutex> lock(random_lock); + boost::lock_guard<boost::mutex> lock(random_lock); ge_p3 tmp3; ec_scalar k; s_comm buf; @@ -280,7 +279,7 @@ POP_WARNINGS const public_key *const *pubs, size_t pubs_count, const secret_key &sec, size_t sec_index, signature *sig) { - lock_guard<mutex> lock(random_lock); + boost::lock_guard<boost::mutex> lock(random_lock); size_t i; ge_p3 image_unp; ge_dsmp image_pre; diff --git a/src/crypto/crypto.h b/src/crypto/crypto.h index 360b571f3..883aa521a 100644 --- a/src/crypto/crypto.h +++ b/src/crypto/crypto.h @@ -31,7 +31,8 @@ #pragma once #include <cstddef> -#include <mutex> +#include <boost/thread/mutex.hpp> +#include <boost/thread/lock_guard.hpp> #include <vector> #include "common/pod-class.h" @@ -44,7 +45,7 @@ namespace crypto { #include "random.h" } - extern std::mutex random_lock; + extern boost::mutex random_lock; #pragma pack(push, 1) POD_CLASS ec_point { @@ -121,7 +122,7 @@ namespace crypto { template<typename T> typename std::enable_if<std::is_pod<T>::value, T>::type rand() { 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); return res; } diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp index 2aa8ecec4..f540697dc 100644 --- a/src/cryptonote_core/blockchain.cpp +++ b/src/cryptonote_core/blockchain.cpp @@ -2105,7 +2105,7 @@ bool Blockchain::check_tx_inputs(const transaction& tx, uint64_t* pmax_used_bloc std::vector < uint64_t > results; results.resize(tx.vin.size(), 0); - int threads = std::thread::hardware_concurrency(); + int threads = boost::thread::hardware_concurrency(); boost::asio::io_service ioservice; boost::thread_group threadpool; @@ -2965,7 +2965,7 @@ bool Blockchain::prepare_handle_incoming_blocks(const std::list<block_complete_e return true; 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) { @@ -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 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()) threads = 1; diff --git a/src/cryptonote_protocol/cryptonote_protocol_handler.h b/src/cryptonote_protocol/cryptonote_protocol_handler.h index c2d428025..1c92958c9 100644 --- a/src/cryptonote_protocol/cryptonote_protocol_handler.h +++ b/src/cryptonote_protocol/cryptonote_protocol_handler.h @@ -134,7 +134,7 @@ namespace cryptonote bool m_one_request = true; // static std::ofstream m_logreq; - std::mutex m_buffer_mutex; + boost::mutex m_buffer_mutex; double get_avg_block_size(); boost::circular_buffer<size_t> m_avg_buffer = boost::circular_buffer<size_t>(10); diff --git a/src/daemonizer/windows_service.cpp b/src/daemonizer/windows_service.cpp index 88f05a305..f8cc0c6c7 100644 --- a/src/daemonizer/windows_service.cpp +++ b/src/daemonizer/windows_service.cpp @@ -99,8 +99,8 @@ namespace { // to allow the user to read any output. void pause_to_display_admin_window_messages() { - std::chrono::milliseconds how_long{1500}; - std::this_thread::sleep_for(how_long); + boost::chrono::milliseconds how_long{1500}; + boost::this_thread::sleep_for(how_long); } } diff --git a/src/daemonizer/windows_service_runner.h b/src/daemonizer/windows_service_runner.h index 2d21509ec..f4258a215 100644 --- a/src/daemonizer/windows_service_runner.h +++ b/src/daemonizer/windows_service_runner.h @@ -56,7 +56,7 @@ namespace windows { private: SERVICE_STATUS_HANDLE m_status_handle{nullptr}; SERVICE_STATUS m_status{}; - std::mutex m_lock{}; + boost::mutex m_lock{}; std::string m_name; T_handler m_handler; diff --git a/src/miner/CMakeLists.txt b/src/miner/CMakeLists.txt index b09ad47aa..d065b9950 100644 --- a/src/miner/CMakeLists.txt +++ b/src/miner/CMakeLists.txt @@ -49,6 +49,7 @@ target_link_libraries(simpleminer ${Boost_FILESYSTEM_LIBRARY} ${Boost_PROGRAM_OPTIONS_LIBRARY} ${Boost_REGEX_LIBRARY} + ${Boost_CHRONO_LIBRARY} ${Boost_SYSTEM_LIBRARY} ${Boost_THREAD_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} diff --git a/src/p2p/data_logger.cpp b/src/p2p/data_logger.cpp index 7fc85e3bc..ca0726c5f 100644 --- a/src/p2p/data_logger.cpp +++ b/src/p2p/data_logger.cpp @@ -40,7 +40,7 @@ namespace epee namespace net_utils { 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"); 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() { _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"); } - std::lock_guard<std::mutex> lock(mMutex); // lock + boost::lock_guard<boost::mutex> lock(mMutex); // lock // prepare all the files for given data channels: 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([&]() { _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 - 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"); 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 } _info_c("dbg/data","Inside thread for data logger - done the main loop"); @@ -106,12 +106,12 @@ namespace net_utils data_logger::~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; } _info_c("dbg/data","State was set to dying"); 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","Thread exited"); @@ -123,7 +123,7 @@ namespace net_utils } 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 (mFilesMap.find(filename) == mFilesMap.end()) { // no such file/counter @@ -151,7 +151,7 @@ namespace net_utils void data_logger::saveToFile() { _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; } nOT::nUtils::cFilesystemUtils::CreateDirTree("log/dr-monero/net/"); 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 std::atomic<bool> data_logger::m_save_graph(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) } // namespace diff --git a/src/p2p/data_logger.hpp b/src/p2p/data_logger.hpp index affc97f5f..148afc0ab 100644 --- a/src/p2p/data_logger.hpp +++ b/src/p2p/data_logger.hpp @@ -33,8 +33,9 @@ #include <map> #include <fstream> #include <memory> -#include <thread> -#include <mutex> +#include <boost/thread/thread.hpp> +#include <boost/thread/mutex.hpp> +#include <boost/thread/once.hpp> #include <atomic> namespace epee @@ -71,7 +72,7 @@ enum class data_logger_state { state_before_init, state_during_init, state_ready static bool is_dying(); 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 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() @@ -94,7 +95,7 @@ enum class data_logger_state { state_before_init, state_during_init, state_ready }; 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 }; diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 56717ec66..6278db891 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -585,7 +585,7 @@ namespace nodetool break; 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 _note("Thread monitor number of peers - done"); })); // lambda diff --git a/src/p2p/network_throttle-detail.cpp b/src/p2p/network_throttle-detail.cpp index 54c82dd8d..ed3c8e7b4 100644 --- a/src/p2p/network_throttle-detail.cpp +++ b/src/p2p/network_throttle-detail.cpp @@ -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) { if (! epee::net_utils::data_logger::m_save_graph) return; - std::mutex mutex; + boost::mutex mutex; mutex.lock(); { std::fstream file; file.open(filename.c_str(), std::ios::app | std::ios::out ); diff --git a/src/p2p/network_throttle.cpp b/src/p2p/network_throttle.cpp index 42f54964b..30538bb3c 100644 --- a/src/p2p/network_throttle.cpp +++ b/src/p2p/network_throttle.cpp @@ -67,9 +67,9 @@ namespace net_utils // ================================================================================================ // static: -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; +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; int network_throttle_manager::xxx; @@ -77,27 +77,27 @@ int network_throttle_manager::xxx; // ================================================================================================ // methods: 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; } -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; 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; } -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; 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; } -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; diff --git a/src/p2p/network_throttle.hpp b/src/p2p/network_throttle.hpp index 6135ed72b..b954c5b3a 100644 --- a/src/p2p/network_throttle.hpp +++ b/src/p2p/network_throttle.hpp @@ -113,16 +113,16 @@ class network_throttle_manager { //protected: public: // XXX // [[note1]] - static std::once_flag m_once_get_global_throttle_in; - static std::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_in; + static boost::once_flag m_once_get_global_throttle_inreq; // [[note2]] + 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_inreq; static std::unique_ptr<i_network_throttle> m_obj_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; + 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; 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! diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 65508b9d5..3e5cdfcb6 100644 --- a/src/simplewallet/simplewallet.cpp +++ b/src/simplewallet/simplewallet.cpp @@ -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)) { 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)) { @@ -1256,7 +1256,7 @@ bool simple_wallet::close_wallet() m_auto_refresh_run.store(false, std::memory_order_relaxed); 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_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()); 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()) { 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); // stop any background refresh, and take over 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(); if (reset) @@ -2434,7 +2434,7 @@ void simple_wallet::wallet_refresh_thread() { 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)) break; m_auto_refresh_refreshing = true; @@ -2447,7 +2447,7 @@ void simple_wallet::wallet_refresh_thread() m_auto_refresh_refreshing = false; if (!m_auto_refresh_run.load(std::memory_order_relaxed)) 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(); if (m_auto_refresh_run) { - m_auto_refresh_thread = std::thread([&]{wallet_refresh_thread();}); + m_auto_refresh_thread = boost::thread([&]{wallet_refresh_thread();}); } else { diff --git a/src/simplewallet/simplewallet.h b/src/simplewallet/simplewallet.h index 5dac60447..d1617dbf4 100644 --- a/src/simplewallet/simplewallet.h +++ b/src/simplewallet/simplewallet.h @@ -242,9 +242,9 @@ namespace cryptonote std::atomic<bool> m_auto_refresh_run; bool m_auto_refresh_refreshing; - std::thread m_auto_refresh_thread; - std::mutex m_auto_refresh_mutex; - std::condition_variable m_auto_refresh_cond; + boost::thread m_auto_refresh_thread; + boost::mutex m_auto_refresh_mutex; + boost::condition_variable m_auto_refresh_cond; std::atomic<bool> m_in_manual_refresh; }; } diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index a86f2ffdf..389286ceb 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -204,7 +204,7 @@ void wallet2::process_new_transaction(const cryptonote::transaction& tx, uint64_ tx_pub_key = pub_key_field.pub_key; bool r = true; - int threads = std::thread::hardware_concurrency(); + int threads = boost::thread::hardware_concurrency(); if (miner_tx && m_refresh_type == RefreshNoCoinbase) { // 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; blocks_added = 0; - int threads = std::thread::hardware_concurrency(); + int threads = boost::thread::hardware_concurrency(); if (threads > 1) { 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; 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::thread pull_thread; + boost::thread pull_thread; uint64_t blocks_start_height; 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; std::list<cryptonote::block_complete_entry> next_blocks; 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); blocks_fetched += added_blocks; @@ -1312,7 +1312,7 @@ bool wallet2::prepare_file_names(const std::string& file_path) //---------------------------------------------------------------------------------------------------- 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()) return true; diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index ceeef492e..c79da2e15 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -407,7 +407,7 @@ namespace tools std::atomic<bool> m_run; - std::mutex m_daemon_rpc_mutex; + boost::mutex m_daemon_rpc_mutex; i_wallet2_callback* m_callback; bool m_testnet; diff --git a/src/wallet/wallet_errors.h b/src/wallet/wallet_errors.h index 10d27651f..80482c1ba 100644 --- a/src/wallet/wallet_errors.h +++ b/src/wallet/wallet_errors.h @@ -31,6 +31,7 @@ #pragma once #include <stdexcept> +#include <system_error> #include <string> #include <vector> |