hans- IPv4 Network Stack

Safe HaskellSafe-Inferred




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.

tryAgain :: Wakeup -> IO () Source

Indicate that the action should be retried.

abort :: Wakeup -> IO () Source

Indicate that the original action will never succeed.


data Incoming Source

Incoming data.

data Outgoing Source

Outgoing data.

Directed Buffers

data Buffer d Source

Data Buffers, in a direction.

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,

isFull :: Buffer d -> Bool Source

A queue is full when there is no available space.

isEmpty :: Buffer d -> Bool Source

A queue is empty when all space is available.

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.

Kernel Side

takeBytes :: Int64 -> Buffer Outgoing -> Maybe (Maybe Wakeup, ByteString, Buffer Outgoing) Source

Take bytes off of a sending queue, making room new data.

putBytes :: ByteString -> Buffer Incoming -> Maybe (Maybe Wakeup, Buffer Incoming) Source

Place bytes on the incoming buffer, provided that there is enough space for all of the bytes.