fix: properly handling infinite timeout for macOS on EventQueue
This commit is contained in:
parent
7743d9008d
commit
c80cd56f27
1 changed files with 3 additions and 2 deletions
|
|
@ -31,9 +31,10 @@ void OSXEventQueueBuffer::waitForEvent(double timeout)
|
||||||
{
|
{
|
||||||
std::unique_lock lock(m_mutex);
|
std::unique_lock lock(m_mutex);
|
||||||
if (m_dataQueue.empty()) {
|
if (m_dataQueue.empty()) {
|
||||||
auto duration = std::chrono::duration<double>(timeout);
|
|
||||||
LOG_DEBUG2("waiting for event, timeout: %f seconds", timeout);
|
LOG_DEBUG2("waiting for event, timeout: %f seconds", timeout);
|
||||||
m_cond.wait_for(lock, duration, [this] { return !m_dataQueue.empty(); });
|
auto end = timeout < 0 ? std::chrono::steady_clock::time_point::max()
|
||||||
|
: std::chrono::steady_clock::now() + std::chrono::duration<double>(timeout);
|
||||||
|
m_cond.wait_until(lock, end, [this] { return !m_dataQueue.empty(); });
|
||||||
} else {
|
} else {
|
||||||
LOG_DEBUG2("found events in the queue");
|
LOG_DEBUG2("found events in the queue");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue