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
60ac3b26
Unverified
Commit
60ac3b26
authored
Sep 07, 2021
by
kladko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
SKALE-4586 Add Agent class
parent
c45204e1
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
121 additions
and
3 deletions
+121
-3
Makefile.am
Makefile.am
+2
-2
Agent.cpp
zmq_src/Agent.cpp
+56
-0
Agent.h
zmq_src/Agent.h
+60
-0
ZMQServer.h
zmq_src/ZMQServer.h
+3
-1
No files found.
Makefile.am
View file @
60ac3b26
...
@@ -71,7 +71,7 @@ bin_PROGRAMS = sgxwallet testw sgx_util
...
@@ -71,7 +71,7 @@ bin_PROGRAMS = sgxwallet testw sgx_util
COMMON_SRC
=
SGXException.cpp ExitHandler.cpp zmq_src/ZMQClient.cpp zmq_src/RspMessage.cpp zmq_src/ReqMessage.cpp
\
COMMON_SRC
=
SGXException.cpp ExitHandler.cpp zmq_src/ZMQClient.cpp zmq_src/RspMessage.cpp zmq_src/ReqMessage.cpp
\
zmq_src/ZMQMessage.cpp zmq_src/ZMQServer.cpp ExitRequestedException.cpp
\
zmq_src/ZMQMessage.cpp zmq_src/ZMQServer.cpp
zmq_src/Agent.cpp
ExitRequestedException.cpp
\
InvalidStateException.cpp Exception.cpp InvalidArgumentException.cpp Log.cpp TECrypto.cpp
\
InvalidStateException.cpp Exception.cpp InvalidArgumentException.cpp Log.cpp TECrypto.cpp
\
SGXWalletServer.cpp SGXRegistrationServer.cpp CSRManagerServer.cpp BLSCrypto.cpp CryptoTools.cpp
\
SGXWalletServer.cpp SGXRegistrationServer.cpp CSRManagerServer.cpp BLSCrypto.cpp CryptoTools.cpp
\
DKGCrypto.cpp ServerInit.cpp BLSPrivateKeyShareSGX.cpp LevelDB.cpp ServerDataChecker.cpp SEKManager.cpp
\
DKGCrypto.cpp ServerInit.cpp BLSPrivateKeyShareSGX.cpp LevelDB.cpp ServerDataChecker.cpp SEKManager.cpp
\
...
...
zmq_src/Agent.cpp
0 → 100644
View file @
60ac3b26
/*
Copyright (C) 2021 SKALE Labs
This file is part of skale-consensus.
skale-consensus is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
skale-consensus is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with skale-consensus. If not, see <https://www.gnu.org/licenses/>.
@file Agent.cpp
@author Stan Kladko
@date 2021
*/
#include "Agent.h"
void
Agent
::
notifyAllConditionVariables
()
{
messageCond
.
notify_all
();
queueCond
.
notify_all
();
}
Agent
::
Agent
()
:
startedRun
(
false
)
{};
void
Agent
::
waitOnGlobalStartBarrier
()
{
unique_lock
<
mutex
>
mlock
(
queueMutex
);
while
(
!
startedRun
)
{
queueCond
.
wait
(
mlock
);
}
}
Agent
::~
Agent
()
{
}
void
Agent
::
releaseGlobalStartBarrier
()
{
if
(
startedRun
.
exchange
(
true
))
{
return
;
}
lock_guard
<
mutex
>
lock
(
queueMutex
);
queueCond
.
notify_all
();
}
zmq_src/Agent.h
0 → 100644
View file @
60ac3b26
/*
Copyright (C) 2021 SKALE Labs
This file is part of skale-consensus.
skale-consensus is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
skale-consensus is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with skale-consensus. If not, see <https://www.gnu.org/licenses/>.
@file Agent.h
@author Stan Kladko
@date 2021
*/
#pragma once
#include <condition_variable>
#include <mutex>
#include <atomic>
using
namespace
std
;
class
Agent
{
protected
:
atomic_bool
startedRun
;
mutex
messageMutex
;
condition_variable
messageCond
;
condition_variable
queueCond
;
mutex
queueMutex
;
recursive_mutex
m
;
public
:
Agent
();
void
notifyAllConditionVariables
();
virtual
~
Agent
();
void
releaseGlobalStartBarrier
();
void
waitOnGlobalStartBarrier
();
recursive_mutex
&
getMainMutex
()
{
return
m
;
}
};
zmq_src/ZMQServer.h
View file @
60ac3b26
...
@@ -35,10 +35,12 @@
...
@@ -35,10 +35,12 @@
#include <zmq.hpp>
#include <zmq.hpp>
#include "zhelpers.hpp"
#include "zhelpers.hpp"
#include "Agent.h"
using
namespace
std
;
using
namespace
std
;
class
ZMQServer
{
class
ZMQServer
:
Agent
{
uint64_t
workerThreads
;
uint64_t
workerThreads
;
...
...
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