Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
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.
- 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 ()
- enqueueControl :: PriorityTree a -> StreamId -> a -> IO ()
- dequeue :: PriorityTree a -> IO (StreamId, Precedence, a)
- delete :: PriorityTree a -> StreamId -> Precedence -> IO (Maybe a)
Precedence
data Precedence Source
Internal representation of priority in priority queues.
The precedence of a dequeued entry should be specified
to enqueue
when the entry is enqueued again.
defaultPrecedence :: Precedence Source
Default precedence.
toPrecedence :: Priority -> Precedence Source
Converting Priority
to Precedence
.
When an entry is enqueued at the first time,
this function should be used.
PriorityTree
data PriorityTree a Source
Abstract data type for priority trees.
newPriorityTree :: IO (PriorityTree a) Source
Creating a new priority tree.
PriorityTree functions
prepare :: PriorityTree a -> StreamId -> Priority -> IO () Source
Bringing up the structure of the priority tree. This must be used for Priority frame.
enqueue :: PriorityTree a -> StreamId -> Precedence -> a -> IO () Source
Enqueuing an entry to the priority tree. This must be used for Header frame.
enqueueControl :: PriorityTree a -> StreamId -> a -> IO () Source
Putting an entry to the top of the priority tree.
dequeue :: PriorityTree a -> IO (StreamId, Precedence, a) Source
Dequeuing an entry from the priority tree.
delete :: PriorityTree a -> StreamId -> Precedence -> IO (Maybe a) Source