2-- Module : Streamly.Internal.Data.Ring
3-- Copyright : (c) 2021 Composewell Technologies
4-- License : BSD-3-Clause
5-- Maintainer : streamly@composewell.com
6-- Stability : experimental
10module Streamly.Internal.Data.Ring
16import Data.IORef (modifyIORef', newIORef, readIORef, writeIORef, IORef)
17import Streamly.Internal.Data.Array.Mut.Type
25 , ringHead :: IORef Int -- current index to be over-written
26 , ringMax :: !Int -- first index beyond allocated memory
29{-# INLINE createRing #-}
30createRing :: Int -> IO (Ring a)
32 arr' <- newArray count
40{-# INLINE unsafeInsertRing #-}
41unsafeInsertRing :: Ring a -> Int -> a -> IO ()
42unsafeInsertRing Ring{..} idx x = do
43 putIndexUnsafe arr (mod idx ringMax) x
44 ref <- readIORef ringHead
46 then modifyIORef' ringHead ( + 1)
47 else writeIORef ringHead 0
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list