ADD: check for timeout when waiting for event
This commit is contained in:
parent
789ce929a4
commit
e7b1eeeaa1
@ -102,8 +102,11 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief wait for a new event with timeout
|
* @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
|
* @brief This method subscribes the participant to an event type
|
||||||
|
@ -94,11 +94,17 @@ void EventManager::Participant::_waitForEvent()
|
|||||||
isQueueLocked_=true;
|
isQueueLocked_=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventManager::Participant::_waitForEvent(std::uint32_t timeoutMS)
|
bool EventManager::Participant::_waitForEvent(std::uint32_t timeoutMS)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(mutexEventQueue_);
|
std::unique_lock<std::mutex> lock(mutexEventQueue_);
|
||||||
newEventInQueue_.wait_for(lock,timeoutMS*1ms);
|
if (newEventInQueue_.wait_for(lock,timeoutMS*1ms)==std::cv_status::no_timeout)
|
||||||
isQueueLocked_=true;
|
{
|
||||||
|
isQueueLocked_=true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user