Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
Abstraction that allows for a choice of timescale when setting alarms. Exposed in a separate module so it can be faked for testing purposes, but client applications should just import Control.Concurrent.AlarmClock.
Synopsis
- class Eq t => TimeScale t where
- getAbsoluteTime :: IO t
- microsecondsDiff :: t -> t -> Integer
- earlierOf :: t -> t -> t
- newtype MonotonicTime = MonotonicTime TimeSpec
Documentation
class Eq t => TimeScale t where Source #
Abstraction that allows for a choice between the UTC timescale and a monotonic timescale, which differ in their handling of irregularities such as clock adjustments and leap seconds.
Alarms set using the UTCTime
timescale wait for the system clock to pass the
given time before going off, and account for the clock being adjusted
backwards and for (positive) leap seconds while waiting. If the clock is set
forwards, or a negative leap second occurs, then the alarm may go off later
than expected by an amount that is roughly equal to the adjustment. It is
possible to correct for this by setting the alarm again after the adjustment
has occurred.
The Monotonic
timescale cannot be so adjusted, which may be more suitable for
some applications.
Note that the timeliness of the alarm going off is very much on a "best effort" basis, and there are many environmental factors that could cause the alarm to go off later than expected.
getAbsoluteTime :: IO t Source #
microsecondsDiff :: t -> t -> Integer Source #
Instances
TimeScale UTCTime Source # | |
TimeScale MonotonicTime Source # | |
Defined in Control.Concurrent.AlarmClock.TimeScale |
newtype MonotonicTime Source #
Representation of system monotonic clock.
Instances
Eq MonotonicTime Source # | |
Defined in Control.Concurrent.AlarmClock.TimeScale (==) :: MonotonicTime -> MonotonicTime -> Bool # (/=) :: MonotonicTime -> MonotonicTime -> Bool # | |
Ord MonotonicTime Source # | |
Defined in Control.Concurrent.AlarmClock.TimeScale compare :: MonotonicTime -> MonotonicTime -> Ordering # (<) :: MonotonicTime -> MonotonicTime -> Bool # (<=) :: MonotonicTime -> MonotonicTime -> Bool # (>) :: MonotonicTime -> MonotonicTime -> Bool # (>=) :: MonotonicTime -> MonotonicTime -> Bool # max :: MonotonicTime -> MonotonicTime -> MonotonicTime # min :: MonotonicTime -> MonotonicTime -> MonotonicTime # | |
Show MonotonicTime Source # | |
Defined in Control.Concurrent.AlarmClock.TimeScale showsPrec :: Int -> MonotonicTime -> ShowS # show :: MonotonicTime -> String # showList :: [MonotonicTime] -> ShowS # | |
TimeScale MonotonicTime Source # | |
Defined in Control.Concurrent.AlarmClock.TimeScale |