Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell98 |
- type Wakeup = Bool -> IO ()
- tryAgain :: Wakeup -> IO ()
- abort :: Wakeup -> IO ()
- data Incoming
- data Outgoing
- data Buffer d
- emptyBuffer :: Int64 -> Buffer d
- shutdownWaiting :: Buffer d -> (IO (), Buffer d)
- isFull :: Buffer d -> Bool
- isEmpty :: Buffer d -> Bool
- flushWaiting :: Buffer d -> (IO (), Buffer d)
- writeBytes :: ByteString -> Wakeup -> Buffer Outgoing -> (Maybe Int64, Buffer Outgoing)
- readBytes :: Int64 -> Wakeup -> Buffer Incoming -> (Maybe ByteString, Buffer Incoming)
- takeBytes :: Int64 -> Buffer Outgoing -> Maybe (Maybe Wakeup, ByteString, Buffer Outgoing)
- putBytes :: ByteString -> Buffer Incoming -> Maybe (Maybe Wakeup, Buffer Incoming)
Delayed work
type Wakeup = Bool -> IO () Source
The boolean parameter indicates whether or not the wakeup is happening in the event of a shutdown, or if the original request should be re-run, allowing more data to flow.
Directions
Directed Buffers
emptyBuffer :: Int64 -> Buffer d Source
An empty buffer, with a limit.
shutdownWaiting :: Buffer d -> (IO (), Buffer d) Source
Run all waiting continuations with a parameter of False,
flushWaiting :: Buffer d -> (IO (), Buffer d) Source
Flush the queue of blocked processes, returning an IO action that negatively acks the waiting processes, and a buffer with an empty wait queue.
Application Side
writeBytes :: ByteString -> Wakeup -> Buffer Outgoing -> (Maybe Int64, Buffer Outgoing) Source
Queue bytes in an outgoing buffer. When there's no space available in the buffer, the wakeup action is queued.
readBytes :: Int64 -> Wakeup -> Buffer Incoming -> (Maybe ByteString, Buffer Incoming) Source
Read bytes from an incoming buffer, queueing if there are no bytes to read.