summaryrefslogtreecommitdiff
path: root/src/Data/PacketQueue.hs
diff options
context:
space:
mode:
authorJames Crayne <jim.crayne@gmail.com>2018-05-25 00:44:56 +0000
committerJames Crayne <jim.crayne@gmail.com>2018-05-25 00:44:56 +0000
commit2eeb6ae431b9badebdcd177fa685246631ec85e5 (patch)
treeff52bc7cd1da7970e38fb2458fc310a29b3a1996 /src/Data/PacketQueue.hs
parent2171aef0c2ffbae3ff407c4f91a33a1b0414c76a (diff)
sessions command, for debuging netcrypto
Diffstat (limited to 'src/Data/PacketQueue.hs')
-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.