Unverified Commit f2bd2ae8 authored by kladko's avatar kladko

SKALE-4586 Added Thread Pool

parent 73e2a031
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <fstream> #include <fstream>
#include <streambuf> #include <streambuf>
#include <boost/functional/hash.hpp>
#include "third_party/spdlog/spdlog.h" #include "third_party/spdlog/spdlog.h"
...@@ -290,14 +291,21 @@ void ZMQServer::doOneServerLoop() { ...@@ -290,14 +291,21 @@ void ZMQServer::doOneServerLoop() {
if ((dynamic_pointer_cast<BLSSignReqMessage>(msg) != nullptr) || if ((dynamic_pointer_cast<BLSSignReqMessage>(msg) != nullptr) ||
dynamic_pointer_cast<ECDSASignReqMessage>(msg)) { dynamic_pointer_cast<ECDSASignReqMessage>(msg)) {
index = NUM_ZMQ_WORKER_THREADS - 1;
boost::hash<std::string> string_hash;
auto hash = string_hash(string((const char*) identity->data()));
index = hash % (NUM_ZMQ_WORKER_THREADS - 1);
} else { } else {
index = 0; index = NUM_ZMQ_WORKER_THREADS - 1;
} }
auto element = pair < shared_ptr < ZMQMessage >, shared_ptr<zmq::message_t>> auto element = pair < shared_ptr < ZMQMessage >, shared_ptr<zmq::message_t>>
(msg, identity); (msg, identity);
incomingQueue.at(index).enqueue(element); incomingQueue.at(index).enqueue(element);
} catch (ExitRequestedException) { } catch (ExitRequestedException) {
......
...@@ -40,7 +40,7 @@ using namespace moodycamel; ...@@ -40,7 +40,7 @@ using namespace moodycamel;
typedef enum {GOT_INCOMING_MSG = 0, GOT_OUTFOING_MSG = 1} PollResult; typedef enum {GOT_INCOMING_MSG = 0, GOT_OUTFOING_MSG = 1} PollResult;
static const uint64_t NUM_ZMQ_WORKER_THREADS = 2; static const uint64_t NUM_ZMQ_WORKER_THREADS = 16;
class ZMQServer : public Agent{ class ZMQServer : public Agent{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment