-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Concurrent expanding buffer -- -- Concurrent expanding buffer @package concurrent-buffer @version 0.1 module ConcurrentBuffer data Buffer -- | Create a new buffer of the specified initial capacity. new :: Int -> IO Buffer -- | Prepares the buffer to be filled with at maximum the specified amount -- of bytes, then uses the pointer-action to populate it. It is your -- responsibility to ensure that the action does not exceed the space -- limit. -- -- The pointer-action returns the amount of bytes it actually writes to -- the buffer. That amount then is used to move the buffer's cursor -- accordingly. It can also produce some result, which will then -- be emitted by push. -- -- It also aligns or grows the buffer if required. push :: Buffer -> Int -> (Ptr Word8 -> IO (Int, result)) -> IO result -- | Push a byte array into the buffer. pushBytes :: Buffer -> ByteString -> IO () -- | Push a storable value into the buffer. pushStorable :: (Storable storable) => Buffer -> storable -> IO () -- | Pulls the specified amount of bytes from the buffer using the provided -- pointer-action, freeing the buffer from the pulled bytes afterwards. -- -- In case the buffer does not contain enough bytes yet, it will block -- waiting. pull :: Buffer -> Int -> (Ptr Word8 -> IO result) -> IO result -- | Pulls the specified amount of bytes. pullBytes :: Buffer -> Int -> IO ByteString -- | Pulls a storable value. pullStorable :: (Storable storable) => Buffer -> IO storable -- | Get how much space is occupied by the buffer's data. getSpace :: Buffer -> IO Int -- | Create a bytestring representation without modifying the buffer. getBytes :: Buffer -> IO ByteString