Skip to content

Commit

Permalink
Adjustment of Barrier behavior to make it similar to other overload
Browse files Browse the repository at this point in the history
  • Loading branch information
codemercenary committed May 23, 2016
1 parent 58335c4 commit 9169062
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/autowiring/DispatchQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,8 @@ void DispatchQueue::PendExisting(std::unique_lock<std::mutex>&& lk, DispatchThun
}

bool DispatchQueue::Barrier(std::chrono::nanoseconds timeout) {
// Optimistic check first:
if (!m_count)
return true;

// Short-circuit if zero is specified as the timeout value
if (timeout.count() == 0)
if (!m_count && timeout.count() == 0)
return false;

// Now lock and double-check:
Expand All @@ -294,10 +290,6 @@ bool DispatchQueue::Barrier(std::chrono::nanoseconds timeout) {
if (onAborted)
throw dispatch_aborted_exception("Dispatch queue was aborted before a timed wait was attempted");

// Short-circuit if the queue is already empty
if (!m_count)
return true;

// Set up the lambda. Note that the queue size CANNOT be 1, because we just checked to verify
// that it is non-empty. Thus, we do not need to signal the m_queueUpdated condition variable.
auto complete = std::make_shared<bool>(false);
Expand Down

0 comments on commit 9169062

Please sign in to comment.