aboutsummaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-01-04 12:20:43 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2017-01-04 12:21:53 +0100
commitd9ae1cefa081c7ef978fab0b288475692678af72 (patch)
treeaaafc90d4a0ef9a6ac14f6787a4d8852705e095f /src/net.h
parentc0ddd32bf629bb48426b0651def497ca1a78e6b1 (diff)
parent67ee4ec9015592c8447955356adfcbb1bf473e32 (diff)
downloadbitcoin-d9ae1cefa081c7ef978fab0b288475692678af72.tar.xz
Merge #9289: net: drop boost::thread_group
67ee4ec net: misc header cleanups (Cory Fields) 8b3159e net: make proxy receives interruptible (Cory Fields) 5cb0fce net: remove thread_interrupted catch (Cory Fields) d3d7056 net: make net processing interruptible (Cory Fields) 0985052 net: make net interruptible (Cory Fields) 799df91 net: add CThreadInterrupt and InterruptibleSleep (Cory Fields) 7325b15 net: a few small cleanups before replacing boost threads (Cory Fields)
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h23
1 files changed, 19 insertions, 4 deletions
diff --git a/src/net.h b/src/net.h
index 1d07864383..6ca402f71d 100644
--- a/src/net.h
+++ b/src/net.h
@@ -19,11 +19,14 @@
#include "streams.h"
#include "sync.h"
#include "uint256.h"
+#include "threadinterrupt.h"
#include <atomic>
#include <deque>
#include <stdint.h>
+#include <thread>
#include <memory>
+#include <condition_variable>
#ifndef WIN32
#include <arpa/inet.h>
@@ -142,8 +145,9 @@ public:
};
CConnman(uint64_t seed0, uint64_t seed1);
~CConnman();
- bool Start(boost::thread_group& threadGroup, CScheduler& scheduler, std::string& strNodeError, Options options);
+ bool Start(CScheduler& scheduler, std::string& strNodeError, Options options);
void Stop();
+ void Interrupt();
bool BindListenPort(const CService &bindAddr, std::string& strError, bool fWhitelisted = false);
bool GetNetworkActive() const { return fNetworkActive; };
void SetNetworkActive(bool active);
@@ -402,7 +406,6 @@ private:
std::list<CNode*> vNodesDisconnected;
mutable CCriticalSection cs_vNodes;
std::atomic<NodeId> nLastNodeId;
- boost::condition_variable messageHandlerCondition;
/** Services this instance offers */
ServiceFlags nLocalServices;
@@ -419,6 +422,18 @@ private:
/** SipHasher seeds for deterministic randomness */
const uint64_t nSeed0, nSeed1;
+
+ std::condition_variable condMsgProc;
+ std::mutex mutexMsgProc;
+ std::atomic<bool> flagInterruptMsgProc;
+
+ CThreadInterrupt interruptNet;
+
+ std::thread threadDNSAddressSeed;
+ std::thread threadSocketHandler;
+ std::thread threadOpenAddedConnections;
+ std::thread threadOpenConnections;
+ std::thread threadMessageHandler;
};
extern std::unique_ptr<CConnman> g_connman;
void Discover(boost::thread_group& threadGroup);
@@ -445,8 +460,8 @@ struct CombinerAll
// Signals for message handling
struct CNodeSignals
{
- boost::signals2::signal<bool (CNode*, CConnman&), CombinerAll> ProcessMessages;
- boost::signals2::signal<bool (CNode*, CConnman&), CombinerAll> SendMessages;
+ boost::signals2::signal<bool (CNode*, CConnman&, std::atomic<bool>&), CombinerAll> ProcessMessages;
+ boost::signals2::signal<bool (CNode*, CConnman&, std::atomic<bool>&), CombinerAll> SendMessages;
boost::signals2::signal<void (CNode*, CConnman&)> InitializeNode;
boost::signals2::signal<void (NodeId, bool&)> FinalizeNode;
};