| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
ConcurrentBuffer
- data Buffer
- new :: Int -> IO Buffer
- push :: Buffer -> Int -> (Ptr Word8 -> IO (Int, result)) -> IO result
- pushBytes :: Buffer -> ByteString -> IO ()
- pushStorable :: Storable storable => Buffer -> storable -> IO ()
- pull :: Buffer -> Int -> (Ptr Word8 -> IO result) -> IO result
- pullBytes :: Buffer -> Int -> IO ByteString
- pullStorable :: Storable storable => Buffer -> IO storable
- getSpace :: Buffer -> IO Int
- getBytes :: Buffer -> IO ByteString
Documentation
push :: Buffer -> Int -> (Ptr Word8 -> IO (Int, result)) -> IO result Source #
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.
pushStorable :: Storable storable => Buffer -> storable -> IO () Source #
Push a storable value into the buffer.