diff options
author | Joe Crayne <joe@jerkface.net> | 2018-09-07 23:27:49 -0400 |
---|---|---|
committer | Joe Crayne <joe@jerkface.net> | 2018-09-07 23:29:18 -0400 |
commit | d9159028e812f2855558ba183d3c11040d98e408 (patch) | |
tree | c7922dd347ba31dda12016543e343ed08e4a743c /src/Data/Wrapper/PSQ.hs | |
parent | 828516059436b6dedf05ff8bff9bab654f12fcc0 (diff) |
Added some minor helper utiltities to PSQ and Network.Tox.Session.
Diffstat (limited to 'src/Data/Wrapper/PSQ.hs')
-rw-r--r-- | src/Data/Wrapper/PSQ.hs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/Data/Wrapper/PSQ.hs b/src/Data/Wrapper/PSQ.hs index 5d32e16c..745e556b 100644 --- a/src/Data/Wrapper/PSQ.hs +++ b/src/Data/Wrapper/PSQ.hs | |||
@@ -22,9 +22,11 @@ fold' f a q = PSQueue.foldr f' a q | |||
22 | -- import Data.OrdPSQ as OrdPSQ hiding (insert, map, singleton, minView) | 22 | -- import Data.OrdPSQ as OrdPSQ hiding (insert, map, singleton, minView) |
23 | -- import qualified Data.OrdPSQ as OrdPSQ | 23 | -- import qualified Data.OrdPSQ as OrdPSQ |
24 | 24 | ||
25 | import Data.HashPSQ as HashPSQ hiding (insert, map, singleton, minView) | ||
26 | import qualified Data.HashPSQ as Q | ||
27 | import Data.Hashable | 25 | import Data.Hashable |
26 | import qualified Data.HashPSQ as Q | ||
27 | ;import Data.HashPSQ as HashPSQ hiding (insert, map, minView, | ||
28 | singleton) | ||
29 | import Data.Time.Clock.POSIX (POSIXTime) | ||
28 | 30 | ||
29 | type PSQ' k p v = HashPSQ k p v | 31 | type PSQ' k p v = HashPSQ k p v |
30 | type PSQ k p = PSQ' k p () | 32 | type PSQ k p = PSQ' k p () |
@@ -78,4 +80,11 @@ minView :: (PSQKey k, Ord p) => PSQ' k p v -> Maybe (Binding' k p v, PSQ' k p v) | |||
78 | minView q = fmap (\(k,p,v,q') -> (Binding k v p, q')) $ Q.minView q | 80 | minView q = fmap (\(k,p,v,q') -> (Binding k v p, q')) $ Q.minView q |
79 | {-# INLINE minView #-} | 81 | {-# INLINE minView #-} |
80 | 82 | ||
83 | |||
84 | -- | Utility to convert a 'POSIXTime' delta into microseconds suitable for | ||
85 | -- passing to 'threadDelay'. | ||
86 | toMicroseconds :: POSIXTime -> Int | ||
87 | toMicroseconds = round . (* 1000) . (* 1000) | ||
88 | |||
89 | |||
81 | #endif | 90 | #endif |