aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
authorHoward Chu <hyc@symas.com>2016-03-11 12:25:28 +0000
committerHoward Chu <hyc@symas.com>2016-03-11 15:09:50 +0000
commitb937a2c915861900d047d4d4a24af31c454e3540 (patch)
treeceedf9b256b9769f72cb34319e4144ae127543dc /contrib
parentMerge pull request #705 (diff)
downloadmonero-b937a2c915861900d047d4d4a24af31c454e3540.tar.xz
Use boost::thread instead of std::thread
and all other associated IPC
Diffstat (limited to '')
-rw-r--r--contrib/epee/include/console_handler.h16
-rw-r--r--contrib/epee/include/net/abstract_tcp_server2.h6
-rw-r--r--contrib/epee/include/net/abstract_tcp_server2.inl4
-rw-r--r--contrib/epee/include/syncobj.h12
-rw-r--r--contrib/otshell_utils/lib_common1.hpp9
-rw-r--r--contrib/otshell_utils/utils.cpp9
-rw-r--r--contrib/otshell_utils/utils.hpp12
7 files changed, 35 insertions, 33 deletions
diff --git a/contrib/epee/include/console_handler.h b/contrib/epee/include/console_handler.h
index d76d7930c..95b986ff5 100644
--- a/contrib/epee/include/console_handler.h
+++ b/contrib/epee/include/console_handler.h
@@ -65,7 +65,7 @@ namespace epee
if (state_eos == m_read_status)
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)
{
m_response_cv.wait(lock);
@@ -104,7 +104,7 @@ namespace epee
private:
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)
return false;
@@ -115,7 +115,7 @@ namespace epee
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)
{
m_request_cv.wait(lock);
@@ -188,7 +188,7 @@ namespace epee
}
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))
{
m_line = std::move(line);
@@ -220,10 +220,10 @@ namespace epee
bool m_has_read_request;
t_state m_read_status;
- std::mutex m_request_mutex;
- std::mutex m_response_mutex;
- std::condition_variable m_request_cv;
- std::condition_variable m_response_cv;
+ boost::mutex m_request_mutex;
+ boost::mutex m_response_mutex;
+ boost::condition_variable m_request_cv;
+ boost::condition_variable m_response_cv;
};
diff --git a/contrib/epee/include/net/abstract_tcp_server2.h b/contrib/epee/include/net/abstract_tcp_server2.h
index f3dd7291c..80f3f6db0 100644
--- a/contrib/epee/include/net/abstract_tcp_server2.h
+++ b/contrib/epee/include/net/abstract_tcp_server2.h
@@ -153,8 +153,8 @@ namespace net_utils
// for calculate speed (last 60 sec)
network_throttle m_throttle_speed_in;
network_throttle m_throttle_speed_out;
- std::mutex m_throttle_speed_in_mutex;
- std::mutex m_throttle_speed_out_mutex;
+ boost::mutex m_throttle_speed_in_mutex;
+ boost::mutex m_throttle_speed_out_mutex;
public:
void setRpcStation();
@@ -307,7 +307,7 @@ namespace net_utils
/// The next connection to be accepted
connection_ptr new_connection_;
- std::mutex connections_mutex;
+ boost::mutex connections_mutex;
std::deque<std::pair<boost::system_time, connection_ptr>> connections_;
}; // class <>boosted_tcp_server
diff --git a/contrib/epee/include/net/abstract_tcp_server2.inl b/contrib/epee/include/net/abstract_tcp_server2.inl
index 4fb6fa75d..698e1947a 100644
--- a/contrib/epee/include/net/abstract_tcp_server2.inl
+++ b/contrib/epee/include/net/abstract_tcp_server2.inl
@@ -41,7 +41,7 @@
#include <boost/utility/value_init.hpp>
#include <boost/asio/deadline_timer.hpp>
#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 "pragma_comp_defs.h"
@@ -294,7 +294,7 @@ PRAGMA_WARNING_DISABLE_VS(4355)
if (delay > 0) {
long int ms = (long int)(delay * 100);
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);
} // any form of sleeping
diff --git a/contrib/epee/include/syncobj.h b/contrib/epee/include/syncobj.h
index 0833b4114..8912fc018 100644
--- a/contrib/epee/include/syncobj.h
+++ b/contrib/epee/include/syncobj.h
@@ -30,11 +30,11 @@
#ifndef __WINH_OBJ_H__
#define __WINH_OBJ_H__
+#include <boost/chrono/duration.hpp>
#include <boost/thread/locks.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/recursive_mutex.hpp>
-#include <thread>
-#include <chrono>
+#include <boost/thread/v2/thread.hpp>
namespace epee
{
@@ -224,10 +224,10 @@ namespace epee
#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 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_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_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) { 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_END() }
diff --git a/contrib/otshell_utils/lib_common1.hpp b/contrib/otshell_utils/lib_common1.hpp
index 456e63fbb..2cb466beb 100644
--- a/contrib/otshell_utils/lib_common1.hpp
+++ b/contrib/otshell_utils/lib_common1.hpp
@@ -19,9 +19,11 @@
#include <functional>
#include <memory>
-#include <thread>
#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
@@ -45,8 +47,7 @@
using std::shared_ptr; \
using std::weak_ptr; \
using std::enable_shared_from_this; \
- using std::mutex; \
- using std::lock_guard; \
+ using boost::lock_guard; \
#endif
diff --git a/contrib/otshell_utils/utils.cpp b/contrib/otshell_utils/utils.cpp
index e1d7d9a14..53cb44dca 100644
--- a/contrib/otshell_utils/utils.cpp
+++ b/contrib/otshell_utils/utils.cpp
@@ -12,6 +12,7 @@
#include <fstream>
#include <iostream>
#include <iomanip>
+#include <chrono>
#include "utils.hpp"
@@ -128,7 +129,7 @@ std::string get_current_time() {
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_Get() {
@@ -302,7 +303,7 @@ mPid2Number_Biggest(0)
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
- 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
}
@@ -347,7 +348,7 @@ std::ostream & cLogger::write_stream(int level, const std::string & channel ) {
output << windows_stream(level);
#endif
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) << "}";
auto nicePid = Pid2Number(getpid());
if (nicePid>0) output << " {p" << nicePid << "}";
@@ -516,7 +517,7 @@ std::string cLogger::endline() const {
#endif
}
-int cLogger::Thread2Number(const std::thread::id id) {
+int cLogger::Thread2Number(const boost::thread::id id) {
auto found = mThread2Number.find( id );
if (found == mThread2Number.end()) { // new one
mThread2Number_Biggest++;
diff --git a/contrib/otshell_utils/utils.hpp b/contrib/otshell_utils/utils.hpp
index 297f13ac0..98508b565 100644
--- a/contrib/otshell_utils/utils.hpp
+++ b/contrib/otshell_utils/utils.hpp
@@ -29,7 +29,7 @@
// #define 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)
#else
#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
-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.
@@ -91,7 +91,7 @@ std::atomic<int> & gLoggerGuardDepth_Get(); // getter for the global singleton o
_dbg_dbg("WRITE DEBUG: LEVEL="<<LEVEL<<" VAR: " << VAR ); \
auto level=LEVEL; short int part=0; \
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; \
try { \
++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 ); \
auto level=LEVEL; short int part=0; \
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; \
try { \
++nOT::nUtils::gLoggerGuardDepth_Get(); \
@@ -253,9 +253,9 @@ class cLogger {
void OpenNewChannel_(const std::string & channel); ///< internal function, will throw in case of problems
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 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
int mPid2Number_Biggest; ///< current biggest value held there (biggest key) - works as growing-only counter basically