diff --git a/include/EventManager/Participant.hpp b/include/EventManager/Participant.hpp index 8a3c76f..5846ca7 100644 --- a/include/EventManager/Participant.hpp +++ b/include/EventManager/Participant.hpp @@ -102,8 +102,11 @@ /** * @brief wait for a new event with timeout + * + * @return true - new event available and queue locked + * @return false - no new event, queue not locked, timeout reached */ - void _waitForEvent(std::uint32_t timeoutMS); + bool _waitForEvent(std::uint32_t timeoutMS); /** * @brief This method subscribes the participant to an event type diff --git a/src/EventManager/Participant.cpp b/src/EventManager/Participant.cpp index 35c2357..5d9f95f 100644 --- a/src/EventManager/Participant.cpp +++ b/src/EventManager/Participant.cpp @@ -94,11 +94,17 @@ void EventManager::Participant::_waitForEvent() isQueueLocked_=true; } -void EventManager::Participant::_waitForEvent(std::uint32_t timeoutMS) +bool EventManager::Participant::_waitForEvent(std::uint32_t timeoutMS) { std::unique_lock lock(mutexEventQueue_); - newEventInQueue_.wait_for(lock,timeoutMS*1ms); - isQueueLocked_=true; + if (newEventInQueue_.wait_for(lock,timeoutMS*1ms)==std::cv_status::no_timeout) + { + isQueueLocked_=true; + return true; + } + + return false; + }