* @brief Get an approximate size of the queue * * Note: This is an approximation and may not be accurate in concurrent * scenarios. * * @return size_t Approximate number of elements in the queue */
| 130 | * @return size_t Approximate number of elements in the queue |
| 131 | */ |
| 132 | [[nodiscard]] auto size() const noexcept -> size_t { |
| 133 | size_t head = head_.load(std::memory_order_relaxed); |
| 134 | size_t tail = tail_.load(std::memory_order_relaxed); |
| 135 | return head >= tail ? head - tail : 0; |
| 136 | } |
| 137 | |
| 138 | /** |
| 139 | * @brief Check if the queue is empty (approximate) |
no outgoing calls