mirror of
https://github.com/badaix/snapcast.git
synced 2025-07-19 01:18:17 +02:00
Remove timeout in getNextPlayerChunk
This commit is contained in:
parent
3e91984d3e
commit
99e147c5aa
5 changed files with 63 additions and 89 deletions
|
@ -59,7 +59,7 @@ public:
|
|||
cond_.notify_one();
|
||||
}
|
||||
|
||||
bool wait_for(std::chrono::milliseconds timeout) const
|
||||
bool wait_for(const std::chrono::microseconds& timeout) const
|
||||
{
|
||||
std::unique_lock<std::mutex> mlock(mutex_);
|
||||
abort_ = false;
|
||||
|
@ -69,12 +69,15 @@ public:
|
|||
return !queue_.empty() && !abort_;
|
||||
}
|
||||
|
||||
bool try_pop(T& item, std::chrono::microseconds timeout)
|
||||
bool try_pop(T& item, const std::chrono::microseconds& timeout = std::chrono::microseconds(0))
|
||||
{
|
||||
std::unique_lock<std::mutex> mlock(mutex_);
|
||||
abort_ = false;
|
||||
if (!cond_.wait_for(mlock, timeout, [this] { return (!queue_.empty() || abort_); }))
|
||||
return false;
|
||||
if (timeout.count() > 0)
|
||||
{
|
||||
if (!cond_.wait_for(mlock, timeout, [this] { return (!queue_.empty() || abort_); }))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (queue_.empty() || abort_)
|
||||
return false;
|
||||
|
@ -85,11 +88,6 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
bool try_pop(T& item, std::chrono::milliseconds timeout)
|
||||
{
|
||||
return try_pop(item, std::chrono::duration_cast<std::chrono::microseconds>(timeout));
|
||||
}
|
||||
|
||||
void pop(T& item)
|
||||
{
|
||||
std::unique_lock<std::mutex> mlock(mutex_);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue