on master help sign in
Add Ring.startOf that returns the ringStart as a Ptr
commite57424d1bcdf11cd0a887503ec3baee7abe398b9 authoradithyaov <adithya@composewell.com> dateSat 7 Nov 2020, 20:12 (6 years ago) parent0463b79
1 file changed+5
src/Streamly/Memory/Ring.hs+5
src/Streamly/Memory/Ring.hs+5
@@ -14,6 +14,7 @@ module Streamly.Memory.Ring
1414 , new
1515 , advance
1616 , moveBy
17+ , startOf
1718
1819 -- * Modification
1920 , unsafeInsert
@@ -58,6 +59,10 @@ data Ring a = Ring
5859 , ringBound :: {-# UNPACK #-} !(Ptr a) -- first address beyond allocated memory
5960 }
6061
62+-- | Get the first address of the ring as a pointer.
63+startOf :: Ring a -> Ptr a
64+startOf = unsafeForeignPtrToPtr . ringStart
65+
6166-- | Create a new ringbuffer and return the ring buffer and the ringHead.
6267-- Returns the ring and the ringHead, the ringHead is same as ringStart.
6368{-# INLINE new #-}