forked from byterazor/EventManager
Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
91ef7ad770 | |||
0198266526 | |||
22ff983817 | |||
caa13b0159 | |||
7a1f5b4ae1 | |||
38c69d8da1 |
48
.drone.yml
Normal file
48
.drone.yml
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
kind: pipeline
|
||||||
|
type: kubernetes
|
||||||
|
name: build-amd64
|
||||||
|
platform:
|
||||||
|
arch: amd64
|
||||||
|
node_selector:
|
||||||
|
kubernetes.io/arch: amd64
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: submodules
|
||||||
|
image: alpine/git
|
||||||
|
commands:
|
||||||
|
- git submodule update --init --recursive
|
||||||
|
|
||||||
|
- name: build-amd64
|
||||||
|
image: debian:bookworm-slim
|
||||||
|
commands:
|
||||||
|
- apt-get update
|
||||||
|
- apt-get -qy install gcc-12 cmake make build-essential
|
||||||
|
- mkdir build
|
||||||
|
- cd build; cmake ..
|
||||||
|
- make -j 4
|
||||||
|
- make test
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: kubernetes
|
||||||
|
name: build-arm64
|
||||||
|
platform:
|
||||||
|
arch: arm64
|
||||||
|
node_selector:
|
||||||
|
kubernetes.io/arch: arm64
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: submodules
|
||||||
|
image: alpine/git
|
||||||
|
commands:
|
||||||
|
- git submodule update --init --recursive
|
||||||
|
|
||||||
|
- name: build-arm64
|
||||||
|
image: debian:bookworm-slim
|
||||||
|
commands:
|
||||||
|
- apt-get update
|
||||||
|
- apt-get -qy install gcc-12 cmake make build-essential
|
||||||
|
- mkdir build
|
||||||
|
- cd build; cmake ..
|
||||||
|
- make -j 4
|
||||||
|
- make test
|
@ -42,7 +42,7 @@
|
|||||||
std::uint64_t responseId_;
|
std::uint64_t responseId_;
|
||||||
|
|
||||||
/// identifies if this event is a response to another event
|
/// identifies if this event is a response to another event
|
||||||
std::atomic<bool> isResponse_;
|
bool isResponse_;
|
||||||
|
|
||||||
/// emitter of the event
|
/// emitter of the event
|
||||||
std::shared_ptr<EventManager::Participant> emitter_;
|
std::shared_ptr<EventManager::Participant> emitter_;
|
||||||
|
@ -181,7 +181,13 @@
|
|||||||
*
|
*
|
||||||
* @param manager - the manager to set
|
* @param manager - the manager to set
|
||||||
*/
|
*/
|
||||||
void setManager(std::shared_ptr<EventManager::Manager> manager) { manager_=manager;_subscribe(EVENT_TYPE_SHUTDOWN);}
|
void setManager(std::shared_ptr<EventManager::Manager> manager)
|
||||||
|
{ manager_=manager;
|
||||||
|
if (manager_!=nullptr)
|
||||||
|
{
|
||||||
|
_subscribe(EVENT_TYPE_SHUTDOWN);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Method to set the unique id of the participant
|
* @brief Method to set the unique id of the participant
|
||||||
|
@ -88,7 +88,10 @@
|
|||||||
throw std::runtime_error("can not stop main thread");
|
throw std::runtime_error("can not stop main thread");
|
||||||
}
|
}
|
||||||
|
|
||||||
mainThread_->join();
|
if (mainThread_->joinable())
|
||||||
|
{
|
||||||
|
mainThread_->join();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventManager::Manager::stopScheduling_()
|
void EventManager::Manager::stopScheduling_()
|
||||||
@ -107,8 +110,11 @@
|
|||||||
throw std::runtime_error("can not stop scheduling thread");
|
throw std::runtime_error("can not stop scheduling thread");
|
||||||
}
|
}
|
||||||
|
|
||||||
schedulingThread_->join();
|
if (schedulingThread_->joinable())
|
||||||
}
|
{
|
||||||
|
schedulingThread_->join();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void EventManager::Manager::start()
|
void EventManager::Manager::start()
|
||||||
{
|
{
|
||||||
@ -288,6 +294,11 @@
|
|||||||
bool EventManager::Manager::empty() const
|
bool EventManager::Manager::empty() const
|
||||||
{
|
{
|
||||||
bool isEmpty=true;
|
bool isEmpty=true;
|
||||||
|
|
||||||
|
while(!commandQueue_.empty())
|
||||||
|
{
|
||||||
|
std::this_thread::sleep_for(std::chrono::milliseconds(100));
|
||||||
|
}
|
||||||
|
|
||||||
for (auto it = eventMap_.begin(); it != eventMap_.end(); ++it)
|
for (auto it = eventMap_.begin(); it != eventMap_.end(); ++it)
|
||||||
{
|
{
|
||||||
@ -383,6 +394,9 @@ void EventManager::Manager::processDisconnect_( std::shared_ptr<EventManager::Pa
|
|||||||
// before the participant gets disconnected it has to be unscheduled
|
// before the participant gets disconnected it has to be unscheduled
|
||||||
processDisableScheduling_( participant );
|
processDisableScheduling_( participant );
|
||||||
|
|
||||||
|
// unsubscribe plugin from all events
|
||||||
|
unsubscribe(participant);
|
||||||
|
|
||||||
std::lock_guard<std::mutex> guard(mutexParticipants_);
|
std::lock_guard<std::mutex> guard(mutexParticipants_);
|
||||||
auto it = std::find( participants_.begin(), participants_.end(), participant );
|
auto it = std::find( participants_.begin(), participants_.end(), participant );
|
||||||
if( it != participants_.end() )
|
if( it != participants_.end() )
|
||||||
|
@ -87,6 +87,11 @@ SCENARIO("Basic Usage of EventManager", "[Manager]")
|
|||||||
manager = std::make_shared<EventManager::Manager>();
|
manager = std::make_shared<EventManager::Manager>();
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
REQUIRE_NOTHROW([&]()
|
||||||
|
{
|
||||||
|
manager->start();
|
||||||
|
}());
|
||||||
|
|
||||||
REQUIRE(manager->empty() == true);
|
REQUIRE(manager->empty() == true);
|
||||||
|
|
||||||
std::shared_ptr<myParticipant> participant0;
|
std::shared_ptr<myParticipant> participant0;
|
||||||
@ -107,11 +112,6 @@ SCENARIO("Basic Usage of EventManager", "[Manager]")
|
|||||||
|
|
||||||
REQUIRE(manager->empty() == false);
|
REQUIRE(manager->empty() == false);
|
||||||
|
|
||||||
REQUIRE_NOTHROW([&]()
|
|
||||||
{
|
|
||||||
manager->start();
|
|
||||||
}());
|
|
||||||
|
|
||||||
REQUIRE(manager->isRunning() == true);
|
REQUIRE(manager->isRunning() == true);
|
||||||
|
|
||||||
WHEN("emitting shutdown event")
|
WHEN("emitting shutdown event")
|
||||||
|
Loading…
Reference in New Issue
Block a user