|
|
@ -21,6 +21,8 @@ |
|
|
|
|
|
|
|
#include "Client.h" |
|
|
|
|
|
|
|
#include <chrono> |
|
|
|
#include <thread> |
|
|
|
#include "Common.h" |
|
|
|
#include "Defaults.h" |
|
|
|
using namespace std; |
|
|
@ -41,18 +43,18 @@ Client::Client(std::string const& _clientVersion, Address _us, std::string const |
|
|
|
m_s.sync(m_tq); |
|
|
|
m_changed = true; |
|
|
|
|
|
|
|
static std::string thread_name = "eth"; |
|
|
|
static const char* c_threadName = "eth"; |
|
|
|
|
|
|
|
#if defined(__APPLE__) |
|
|
|
static dispatch_once_t onceToken; |
|
|
|
dispatch_once(&onceToken, ^{ |
|
|
|
m_work = dispatch_queue_create(thread_name.c_str(), DISPATCH_QUEUE_SERIAL); |
|
|
|
m_work = dispatch_queue_create(c_threadName, DISPATCH_QUEUE_SERIAL); |
|
|
|
}); |
|
|
|
|
|
|
|
dispatch_async(m_work, ^{ |
|
|
|
#else |
|
|
|
m_work = new thread([&](){ |
|
|
|
setThreadName(thread_name); |
|
|
|
setThreadName(c_threadName); |
|
|
|
#endif |
|
|
|
|
|
|
|
while (m_workState != Deleting) work(); m_workState = Deleted; |
|
|
@ -64,7 +66,7 @@ Client::~Client() |
|
|
|
if (m_workState == Active) |
|
|
|
m_workState = Deleting; |
|
|
|
while (m_workState != Deleted) |
|
|
|
usleep(10000); |
|
|
|
this_thread::sleep_for(chrono::milliseconds(10000)); |
|
|
|
} |
|
|
|
|
|
|
|
void Client::startNetwork(short _listenPort, std::string const& _seedHost, short _port, NodeMode _mode, unsigned _peers, string const& _publicIP, bool _upnp) |
|
|
@ -158,7 +160,7 @@ void Client::work() |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
usleep(100000); |
|
|
|
this_thread::sleep_for(chrono::milliseconds(100000)); |
|
|
|
} |
|
|
|
|
|
|
|
void Client::lock() |
|
|
|