summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Data/PacketQueue.hs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/Data/PacketQueue.hs b/src/Data/PacketQueue.hs
index b7737656..a4c99cab 100644
--- a/src/Data/PacketQueue.hs
+++ b/src/Data/PacketQueue.hs
@@ -11,6 +11,7 @@ module Data.PacketQueue
11 , enqueue 11 , enqueue
12 , observeOutOfBand 12 , observeOutOfBand
13 , PacketOutQueue 13 , PacketOutQueue
14 , packetQueueViewList
14 , newOutGoing 15 , newOutGoing
15 , readyOutGoing 16 , readyOutGoing
16 , tryAppendQueueOutgoing 17 , tryAppendQueueOutgoing
@@ -25,6 +26,7 @@ import Control.Concurrent.STM.TArray
25import Control.Monad 26import Control.Monad
26import Data.Word 27import Data.Word
27import Data.Array.MArray 28import Data.Array.MArray
29import Data.Maybe
28 30
29data PacketQueue a = PacketQueue 31data PacketQueue a = PacketQueue
30 { pktq :: TArray Word32 (Maybe a) 32 { pktq :: TArray Word32 (Maybe a)
@@ -33,6 +35,13 @@ data PacketQueue a = PacketQueue
33 , buffend :: TVar Word32 -- on incoming, highest packet number handled + 1 35 , buffend :: TVar Word32 -- on incoming, highest packet number handled + 1
34 } 36 }
35 37
38packetQueueViewList :: PacketQueue a -> STM [(Word32,a)]
39packetQueueViewList p = do
40 let f (n,Nothing) = Nothing
41 f (n,Just x) = Just (n,x)
42 catMaybes . map f <$> getAssocs (pktq p)
43
44
36-- | Create a new PacketQueue. 45-- | Create a new PacketQueue.
37new :: Word32 -- ^ Capacity of queue. 46new :: Word32 -- ^ Capacity of queue.
38 -> Word32 -- ^ Initial sequence number. 47 -> Word32 -- ^ Initial sequence number.