summaryrefslogtreecommitdiff
path: root/VectorRing.hs
blob: 2ddac72fa45ae7343ae3d2a6a02b952403c13a5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
module VectorRing where

import Data.Vector.Unboxed.Mutable
import RingBuffer

-- | Typical usage:
--
-- > ringBuffer <- newRing capacity (VectorRing.new capacity)
new :: Unbox a => Int -> IO (TargetBuffer a)
new sz = do
    v <- unsafeNew sz
    return () :: IO ()
    return TargetBuffer
        { syncBuffer   = \_ -> return ()
        , updateBuffer = \i u -> write v i u
        }