aboutsummaryrefslogtreecommitdiffstats
path: root/alc
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-01-14 10:17:57 -0800
committerChris Robinson <[email protected]>2020-01-14 10:17:57 -0800
commit400c768e2fa5ea7ce72f2c4235f2363012153ac9 (patch)
tree7d9b84f563606ffd4bdad07aafdb2ff9f9e93b81 /alc
parente889282131a8d6bb4dd8efea6b4e1f65fe38f0f4 (diff)
Inline a couple ring buffer methods
Diffstat (limited to 'alc')
-rw-r--r--alc/ringbuffer.cpp15
-rw-r--r--alc/ringbuffer.h16
2 files changed, 14 insertions, 17 deletions
diff --git a/alc/ringbuffer.cpp b/alc/ringbuffer.cpp
index 2918ce97..f4146a7d 100644
--- a/alc/ringbuffer.cpp
+++ b/alc/ringbuffer.cpp
@@ -66,21 +66,6 @@ void RingBuffer::reset() noexcept
}
-size_t RingBuffer::readSpace() const noexcept
-{
- size_t w = mWritePtr.load(std::memory_order_acquire);
- size_t r = mReadPtr.load(std::memory_order_acquire);
- return (w-r) & mSizeMask;
-}
-
-size_t RingBuffer::writeSpace() const noexcept
-{
- size_t w = mWritePtr.load(std::memory_order_acquire);
- size_t r = mReadPtr.load(std::memory_order_acquire) + mWriteSize - mSizeMask;
- return (r-w-1) & mSizeMask;
-}
-
-
size_t RingBuffer::read(void *dest, size_t cnt) noexcept
{
const size_t free_cnt{readSpace()};
diff --git a/alc/ringbuffer.h b/alc/ringbuffer.h
index 78bea846..32fb951c 100644
--- a/alc/ringbuffer.h
+++ b/alc/ringbuffer.h
@@ -57,7 +57,13 @@ public:
* Return the number of elements available for reading. This is the number
* of elements in front of the read pointer and behind the write pointer.
*/
- size_t readSpace() const noexcept;
+ size_t readSpace() const noexcept
+ {
+ const size_t w{mWritePtr.load(std::memory_order_acquire)};
+ const size_t r{mReadPtr.load(std::memory_order_acquire)};
+ return (w-r) & mSizeMask;
+ }
+
/**
* The copying data reader. Copy at most `cnt' elements into `dest'.
* Returns the actual number of elements copied.
@@ -75,7 +81,13 @@ public:
* Return the number of elements available for writing. This is the number
* of elements in front of the write pointer and behind the read pointer.
*/
- size_t writeSpace() const noexcept;
+ size_t writeSpace() const noexcept
+ {
+ const size_t w{mWritePtr.load(std::memory_order_acquire)};
+ const size_t r{mReadPtr.load(std::memory_order_acquire) + mWriteSize - mSizeMask};
+ return (r-w-1) & mSizeMask;
+ }
+
/**
* The copying data writer. Copy at most `cnt' elements from `src'. Returns
* the actual number of elements copied.