MCPcopy Create free account
hub / github.com/cameron314/concurrentqueue / is_empty

Method is_empty

concurrentqueue.h:1592–1611  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1590
1591 template<InnerQueueContext context>
1592 inline bool is_empty() const
1593 {
1594 MOODYCAMEL_CONSTEXPR_IF (context == explicit_context && BLOCK_SIZE <= EXPLICIT_BLOCK_EMPTY_COUNTER_THRESHOLD) {
1595 // Check flags
1596 for (size_t i = 0; i < BLOCK_SIZE; ++i) {
1597 if (!emptyFlags[i].load(std::memory_order_relaxed)) {
1598 return false;
1599 }
1600 }
1601
1602 // Aha, empty; make sure we have all other memory effects that happened before the empty flags were set
1603 std::atomic_thread_fence(std::memory_order_acquire);
1604 return true;
1605 }
1606 else {
1607 // Check counter
1608 if (elementsCompletelyDequeued.load(std::memory_order_relaxed) == BLOCK_SIZE) {
1609 std::atomic_thread_fence(std::memory_order_acquire);
1610 return true;
1611 }
1612 assert(elementsCompletelyDequeued.load(std::memory_order_relaxed) <= BLOCK_SIZE);
1613 return false;
1614 }

Callers

nothing calls this directly

Calls 4

MOODYCAMEL_CONSTEXPR_IFFunction · 0.85
atomic_thread_fenceFunction · 0.85
ifFunction · 0.85
loadMethod · 0.45

Tested by

no test coverage detected