Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sgxwallet
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
董子豪
sgxwallet
Commits
f457b201
Unverified
Commit
f457b201
authored
Sep 09, 2021
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-4586 Added Thread Pool
parent
ecde0240
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
1018 additions
and
996 deletions
+1018
-996
atomicops.h
third_party/atomicops.h
+385
-362
readerwriterqueue.h
third_party/readerwriterqueue.h
+617
-630
ZMQServer.cpp
zmq_src/ZMQServer.cpp
+12
-2
ZMQServer.h
zmq_src/ZMQServer.h
+4
-2
No files found.
third_party/atomicops.h
View file @
f457b201
This diff is collapsed.
Click to expand it.
third_party/readerwriterqueue.h
View file @
f457b201
This diff is collapsed.
Click to expand it.
zmq_src/ZMQServer.cpp
View file @
f457b201
...
...
@@ -42,9 +42,11 @@ using namespace std;
shared_ptr
<
ZMQServer
>
ZMQServer
::
zmqServer
=
nullptr
;
ZMQServer
::
ZMQServer
(
bool
_checkSignature
,
bool
_checkKeyOwnership
,
const
string
&
_caCertFile
)
:
outgo
ingQueue
(
NUM_ZMQ_WORKER_THREADS
),
checkSignature
(
_checkSignature
),
checkKeyOwnership
(
_checkKeyOwnership
),
:
incom
ingQueue
(
NUM_ZMQ_WORKER_THREADS
),
checkSignature
(
_checkSignature
),
checkKeyOwnership
(
_checkKeyOwnership
),
caCertFile
(
_caCertFile
),
ctx
(
make_shared
<
zmq
::
context_t
>
(
1
))
{
CHECK_STATE
(
NUM_ZMQ_WORKER_THREADS
>
1
);
socket
=
make_shared
<
zmq
::
socket_t
>
(
*
ctx
,
ZMQ_ROUTER
);
if
(
_checkSignature
)
{
...
...
@@ -277,12 +279,20 @@ void ZMQServer::doOneServerLoop() {
CHECK_STATE2
(
msg
,
ZMQ_COULD_NOT_PARSE
);
uint64_t
index
=
0
;
if
((
dynamic_pointer_cast
<
BLSSignReqMessage
>
(
msg
)
!=
nullptr
)
||
dynamic_pointer_cast
<
ECDSASignReqMessage
>
(
msg
))
{
index
=
NUM_ZMQ_WORKER_THREADS
-
1
;
}
else
{
index
=
0
;
}
auto
element
=
pair
<
shared_ptr
<
ZMQMessage
>
,
shared_ptr
<
zmq
::
message_t
>>
(
msg
,
identity
);
incomingQueue
.
at
(
index
).
enqueue
(
element
);
result
=
msg
->
process
();
}
catch
(
ExitRequestedException
)
{
throw
;
...
...
zmq_src/ZMQServer.h
View file @
f457b201
...
...
@@ -34,6 +34,7 @@
#include "Agent.h"
#include "WorkerThreadPool.h"
#include "ZMQMessage.h"
using
namespace
moodycamel
;
...
...
@@ -41,6 +42,7 @@ typedef enum {GOT_INCOMING_MSG = 0, GOT_OUTFOING_MSG = 1} PollResult;
static
const
uint64_t
NUM_ZMQ_WORKER_THREADS
=
2
;
class
ZMQServer
:
public
Agent
{
uint64_t
workerThreads
;
...
...
@@ -48,9 +50,9 @@ class ZMQServer : public Agent{
string
caCertFile
;
string
caCert
;
ReaderWriterQueue
<
pair
<
string
,
shared_ptr
<
zmq
_msg
_t
>>>
outgoingQueue
;
ReaderWriterQueue
<
pair
<
string
,
shared_ptr
<
zmq
::
message
_t
>>>
outgoingQueue
;
vector
<
ReaderWriterQueue
<
pair
<
s
tring
,
shared_ptr
<
zmq_msg
_t
>>>>
incomingQueue
;
vector
<
ReaderWriterQueue
<
pair
<
s
hared_ptr
<
ZMQMessage
>
,
shared_ptr
<
zmq
::
message
_t
>>>>
incomingQueue
;
bool
checkKeyOwnership
=
true
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment