mirror of
https://github.com/dashpay/dash.git
synced 2024-12-28 13:32:47 +01:00
Merge pull request #2553 from Diapolo/threads
changes to thread code (directly use boost::thread)
This commit is contained in:
commit
d1020b780a
11
src/net.cpp
11
src/net.cpp
@ -389,11 +389,8 @@ bool GetMyExternalIP(CNetAddr& ipRet)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThreadGetMyExternalIP(void* parg)
|
void ThreadGetMyExternalIP()
|
||||||
{
|
{
|
||||||
// Make this thread recognisable as the external IP detection thread
|
|
||||||
RenameThread("bitcoin-ext-ip");
|
|
||||||
|
|
||||||
CNetAddr addrLocalHost;
|
CNetAddr addrLocalHost;
|
||||||
if (GetMyExternalIP(addrLocalHost))
|
if (GetMyExternalIP(addrLocalHost))
|
||||||
{
|
{
|
||||||
@ -1151,7 +1148,7 @@ void MapPort(bool fUseUPnP)
|
|||||||
upnp_thread->join();
|
upnp_thread->join();
|
||||||
delete upnp_thread;
|
delete upnp_thread;
|
||||||
}
|
}
|
||||||
upnp_thread = new boost::thread(boost::bind(&TraceThread<boost::function<void()> >, "upnp", &ThreadMapPort));
|
upnp_thread = new boost::thread(boost::bind(&TraceThread<void (*)()>, "upnp", &ThreadMapPort));
|
||||||
}
|
}
|
||||||
else if (upnp_thread) {
|
else if (upnp_thread) {
|
||||||
upnp_thread->interrupt();
|
upnp_thread->interrupt();
|
||||||
@ -1800,7 +1797,7 @@ void static Discover()
|
|||||||
|
|
||||||
// Don't use external IPv4 discovery, when -onlynet="IPv6"
|
// Don't use external IPv4 discovery, when -onlynet="IPv6"
|
||||||
if (!IsLimited(NET_IPV4))
|
if (!IsLimited(NET_IPV4))
|
||||||
NewThread(ThreadGetMyExternalIP, NULL);
|
boost::thread(boost::bind(&TraceThread<void (*)()>, "ext-ip", &ThreadGetMyExternalIP));
|
||||||
}
|
}
|
||||||
|
|
||||||
void StartNode(boost::thread_group& threadGroup)
|
void StartNode(boost::thread_group& threadGroup)
|
||||||
@ -1823,7 +1820,7 @@ void StartNode(boost::thread_group& threadGroup)
|
|||||||
if (!GetBoolArg("-dnsseed", true))
|
if (!GetBoolArg("-dnsseed", true))
|
||||||
printf("DNS seeding disabled\n");
|
printf("DNS seeding disabled\n");
|
||||||
else
|
else
|
||||||
threadGroup.create_thread(boost::bind(&TraceThread<boost::function<void()> >, "dnsseed", &ThreadDNSAddressSeed));
|
threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "dnsseed", &ThreadDNSAddressSeed));
|
||||||
|
|
||||||
#ifdef USE_UPNP
|
#ifdef USE_UPNP
|
||||||
// Map ports with UPnP
|
// Map ports with UPnP
|
||||||
|
12
src/util.cpp
12
src/util.cpp
@ -1468,15 +1468,3 @@ void RenameThread(const char* name)
|
|||||||
(void)name;
|
(void)name;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NewThread(void(*pfn)(void*), void* parg)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
boost::thread(pfn, parg); // thread detaches when out of scope
|
|
||||||
} catch(boost::thread_resource_error &e) {
|
|
||||||
printf("Error creating thread: %s\n", e.what());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
@ -488,8 +488,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool NewThread(void(*pfn)(void*), void* parg);
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
inline void SetThreadPriority(int nPriority)
|
inline void SetThreadPriority(int nPriority)
|
||||||
{
|
{
|
||||||
@ -500,7 +498,7 @@ inline void SetThreadPriority(int nPriority)
|
|||||||
#define THREAD_PRIORITY_LOWEST PRIO_MAX
|
#define THREAD_PRIORITY_LOWEST PRIO_MAX
|
||||||
#define THREAD_PRIORITY_BELOW_NORMAL 2
|
#define THREAD_PRIORITY_BELOW_NORMAL 2
|
||||||
#define THREAD_PRIORITY_NORMAL 0
|
#define THREAD_PRIORITY_NORMAL 0
|
||||||
#define THREAD_PRIORITY_ABOVE_NORMAL 0
|
#define THREAD_PRIORITY_ABOVE_NORMAL (-2)
|
||||||
|
|
||||||
inline void SetThreadPriority(int nPriority)
|
inline void SetThreadPriority(int nPriority)
|
||||||
{
|
{
|
||||||
@ -512,11 +510,6 @@ inline void SetThreadPriority(int nPriority)
|
|||||||
setpriority(PRIO_PROCESS, 0, nPriority);
|
setpriority(PRIO_PROCESS, 0, nPriority);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void ExitThread(size_t nExitCode)
|
|
||||||
{
|
|
||||||
pthread_exit((void*)nExitCode);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void RenameThread(const char* name);
|
void RenameThread(const char* name);
|
||||||
|
Loading…
Reference in New Issue
Block a user