From d9159028e812f2855558ba183d3c11040d98e408 Mon Sep 17 00:00:00 2001 From: Joe Crayne Date: Fri, 7 Sep 2018 23:27:49 -0400 Subject: Added some minor helper utiltities to PSQ and Network.Tox.Session. --- src/Data/Wrapper/PSQ.hs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/Data/Wrapper/PSQ.hs') 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 -- import Data.OrdPSQ as OrdPSQ hiding (insert, map, singleton, minView) -- import qualified Data.OrdPSQ as OrdPSQ -import Data.HashPSQ as HashPSQ hiding (insert, map, singleton, minView) -import qualified Data.HashPSQ as Q import Data.Hashable +import qualified Data.HashPSQ as Q + ;import Data.HashPSQ as HashPSQ hiding (insert, map, minView, + singleton) +import Data.Time.Clock.POSIX (POSIXTime) type PSQ' k p v = HashPSQ k p v 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) minView q = fmap (\(k,p,v,q') -> (Binding k v p, q')) $ Q.minView q {-# INLINE minView #-} + +-- | Utility to convert a 'POSIXTime' delta into microseconds suitable for +-- passing to 'threadDelay'. +toMicroseconds :: POSIXTime -> Int +toMicroseconds = round . (* 1000) . (* 1000) + + #endif -- cgit v1.2.3