http2-1.6.3: HTTP/2 library including frames, priority queues and HPACK

Safe Haskell | Safe
Language | Haskell2010

Network.HTTP2.Priority

Contents

- Precedence
- PriorityTree
- PriorityTree functions

Description

This is partial implementation of the priority of HTTP/2.

This implementation does support structured priority queue but not support re-structuring. This means that it is assumed that an entry created by a Priority frame is never closed. The entry behaves an intermediate node, not a leaf.

This queue is fair for weight. Consider two weights: 201 and 101. Repeating enqueue/dequeue probably produces 201, 201, 101, 201, 201, 101, ...

Only one entry per stream should be enqueued.

Synopsis

- data Precedence
- defaultPrecedence :: Precedence
- toPrecedence :: Priority -> Precedence
- data PriorityTree a
- newPriorityTree :: IO (PriorityTree a)
- prepare :: PriorityTree a -> StreamId -> Priority -> IO ()
- enqueue :: PriorityTree a -> StreamId -> Precedence -> a -> IO ()
- dequeue :: PriorityTree a -> IO (StreamId, Precedence, a)
- dequeueSTM :: PriorityTree a -> STM (StreamId, Precedence, a)
- isEmpty :: PriorityTree a -> IO Bool
- isEmptySTM :: PriorityTree a -> STM Bool
- delete :: PriorityTree a -> StreamId -> Precedence -> IO (Maybe a)

# Precedence

data Precedence #

Internal representation of priority in priority queues. The precedence of a dequeued entry should be specified to `enqueue` when the entry is enqueued again.

Instances

Eq Precedence # |
Methods (==) :: Precedence -> Precedence -> Bool # (/=) :: Precedence -> Precedence -> Bool #
Ord Precedence # |
Methods compare :: Precedence -> Precedence -> Ordering # (<) :: Precedence -> Precedence -> Bool # (<=) :: Precedence -> Precedence -> Bool # (>) :: Precedence -> Precedence -> Bool # (>=) :: Precedence -> Precedence -> Bool # max :: Precedence -> Precedence -> Precedence # min :: Precedence -> Precedence -> Precedence #
Show Precedence # |
Methods showsPrec :: Int -> Precedence -> ShowS # show :: Precedence -> String # showList :: [Precedence] -> ShowS #

defaultPrecedence :: Precedence #

Default precedence.

toPrecedence :: Priority -> Precedence #

Converting `Priority` to `Precedence`. When an entry is enqueued at the first time, this function should be used.

# PriorityTree

data PriorityTree a #

Abstract data type for priority trees.

newPriorityTree :: IO (PriorityTree a) #

Creating a new priority tree.

# PriorityTree functions

prepare :: PriorityTree a -> StreamId -> Priority -> IO () #

Bringing up the structure of the priority tree. This must be used for Priority frame.

enqueue :: PriorityTree a -> StreamId -> Precedence -> a -> IO () #

Enqueuing an entry to the priority tree. This must be used for Header frame.

dequeue :: PriorityTree a -> IO (StreamId, Precedence, a) #

Dequeuing an entry from the priority tree.

dequeueSTM :: PriorityTree a -> STM (StreamId, Precedence, a) #

Dequeuing an entry from the priority tree.

isEmpty :: PriorityTree a -> IO Bool #

Checking if the priority tree is empty.

isEmptySTM :: PriorityTree a -> STM Bool #

Checking if the priority tree is empty.

delete :: PriorityTree a -> StreamId -> Precedence -> IO (Maybe a) #

Deleting the entry corresponding to `StreamId`. `delete` and `enqueue` are used to change the priority of a live stream.