diff options
author | James Crayne <jim.crayne@gmail.com> | 2018-05-25 00:44:56 +0000 |
---|---|---|
committer | James Crayne <jim.crayne@gmail.com> | 2018-05-25 00:44:56 +0000 |
commit | 2eeb6ae431b9badebdcd177fa685246631ec85e5 (patch) | |
tree | ff52bc7cd1da7970e38fb2458fc310a29b3a1996 /src/Data/PacketQueue.hs | |
parent | 2171aef0c2ffbae3ff407c4f91a33a1b0414c76a (diff) |
sessions command, for debuging netcrypto
Diffstat (limited to 'src/Data/PacketQueue.hs')
-rw-r--r-- | src/Data/PacketQueue.hs | 9 |
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 | |||
25 | import Control.Monad | 26 | import Control.Monad |
26 | import Data.Word | 27 | import Data.Word |
27 | import Data.Array.MArray | 28 | import Data.Array.MArray |
29 | import Data.Maybe | ||
28 | 30 | ||
29 | data PacketQueue a = PacketQueue | 31 | data 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 | ||
38 | packetQueueViewList :: PacketQueue a -> STM [(Word32,a)] | ||
39 | packetQueueViewList 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. |
37 | new :: Word32 -- ^ Capacity of queue. | 46 | new :: Word32 -- ^ Capacity of queue. |
38 | -> Word32 -- ^ Initial sequence number. | 47 | -> Word32 -- ^ Initial sequence number. |