| 246 | */ |
| 247 | template<typename T, Concepts::ByteLike StorageType> |
| 248 | qsizetype IO::CircularBuffer<T, StorageType>::size() const noexcept |
| 249 | { |
| 250 | const qsizetype head = m_head.load(std::memory_order_acquire); |
| 251 | const qsizetype tail = m_tail.load(std::memory_order_acquire); |
| 252 | |
| 253 | if (tail >= head) |
| 254 | return tail - head; |
| 255 | else |
| 256 | return m_capacity - head + tail; |
| 257 | } |
| 258 | |
| 259 | /** |
| 260 | * @brief Returns the free space available in the buffer. |