factor out Utility.MonotonicClock
This commit is contained in:
parent
543c610a31
commit
5b6150e5d5
5 changed files with 30 additions and 15 deletions
24
Utility/MonotonicClock.hs
Normal file
24
Utility/MonotonicClock.hs
Normal file
|
@ -0,0 +1,24 @@
|
|||
{- Monotonic clocks
|
||||
-
|
||||
- Copyright 2024 Joey Hess <id@joeyh.name>
|
||||
-
|
||||
- License: BSD-2-clause
|
||||
-}
|
||||
|
||||
{-# LANGUAGE CPP #-}
|
||||
|
||||
module Utility.MonotonicClock where
|
||||
|
||||
#if MIN_VERSION_clock(0,3,0)
|
||||
import qualified System.Clock as Clock
|
||||
#else
|
||||
import qualified System.Posix.Clock as Clock
|
||||
#endif
|
||||
|
||||
newtype MonotonicTimestamp = MonotonicTimestamp Integer
|
||||
deriving (Show, Eq, Ord)
|
||||
|
||||
currentMonotonicTimestamp :: IO MonotonicTimestamp
|
||||
currentMonotonicTimestamp =
|
||||
(MonotonicTimestamp . fromIntegral . Clock.sec)
|
||||
<$> Clock.getTime Clock.Monotonic
|
Loading…
Add table
Add a link
Reference in a new issue