Compare commits

...

3 Commits

Author SHA1 Message Date
Dominik Meyer 91ef7ad770
FIX: fixed empty bug
continuous-integration/drone Build is passing Details
2024-01-16 12:41:45 +01:00
Dominik Meyer 0198266526
FIX: removed unnecessary atomic 2024-01-16 12:27:12 +01:00
Dominik Meyer 22ff983817
FIX: test if thread is joinable before join 2024-01-16 12:25:53 +01:00
3 changed files with 20 additions and 9 deletions

View File

@ -42,7 +42,7 @@
std::uint64_t responseId_;
/// identifies if this event is a response to another event
std::atomic<bool> isResponse_;
bool isResponse_;
/// emitter of the event
std::shared_ptr<EventManager::Participant> emitter_;

View File

@ -88,7 +88,10 @@
throw std::runtime_error("can not stop main thread");
}
mainThread_->join();
if (mainThread_->joinable())
{
mainThread_->join();
}
}
void EventManager::Manager::stopScheduling_()
@ -107,8 +110,11 @@
throw std::runtime_error("can not stop scheduling thread");
}
schedulingThread_->join();
}
if (schedulingThread_->joinable())
{
schedulingThread_->join();
}
}
void EventManager::Manager::start()
{
@ -288,6 +294,11 @@
bool EventManager::Manager::empty() const
{
bool isEmpty=true;
while(!commandQueue_.empty())
{
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
for (auto it = eventMap_.begin(); it != eventMap_.end(); ++it)
{

View File

@ -87,6 +87,11 @@ SCENARIO("Basic Usage of EventManager", "[Manager]")
manager = std::make_shared<EventManager::Manager>();
}());
REQUIRE_NOTHROW([&]()
{
manager->start();
}());
REQUIRE(manager->empty() == true);
std::shared_ptr<myParticipant> participant0;
@ -107,11 +112,6 @@ SCENARIO("Basic Usage of EventManager", "[Manager]")
REQUIRE(manager->empty() == false);
REQUIRE_NOTHROW([&]()
{
manager->start();
}());
REQUIRE(manager->isRunning() == true);
WHEN("emitting shutdown event")