Portability | Tested on Linux and Windows |
---|---|
Maintainer | joeyadams3.14159@gmail.com |
Safe Haskell | Safe-Infered |
This module provides more direct access to the system's monotonic clock, but provides less protection against wraparound.
More specifically, in the higher-level System.Time.Monotonic API,
Clock
updates its internal disposition every time
clockGetTime
is called. The only way to get a
wraparound issue with the higher-level API is to call
clockGetTime
very seldomly (e.g. less than once
every 24.8 days, if GetTickCount
is being used).
- getSystemClock :: IO SomeSystemClock
- data SomeSystemClock = forall time cumtime . SomeSystemClock (SystemClock time cumtime)
- data SystemClock time cumtime = SystemClock {
- systemClockGetTime :: IO time
- systemClockDiffTime :: time -> time -> cumtime
- systemClockZeroCumTime :: cumtime
- systemClockAddCumTime :: cumtime -> cumtime -> cumtime
- systemClockCumToDiff :: cumtime -> DiffTime
- systemClockName :: String
- systemClock_MONOTONIC :: SystemClock CTimeSpec DiffTime
- data CTimeSpec
Documentation
getSystemClock :: IO SomeSystemClockSource
Return a module used for accessing the system's monotonic clock. The
reason this is an IO
action, rather than simply a SystemClock
value, is
that the implementation may need to make a system call to determine what
monotonic time source to use, and how to use it.
data SomeSystemClock Source
Existentially-quantified wrapper around SystemClock
forall time cumtime . SomeSystemClock (SystemClock time cumtime) |
data SystemClock time cumtime Source
A SystemClock
is a driver module used by Clock
to access a particular implementation of monotonic time support.
-
time
: Type of value returned by the system's time-getting function. -
cumtime
: Type for accumulating differences between consecutive(-ish) calls tosystemClockGetTime
, in casetime
wraps around. The reason we don't simply useDiffTime
is this: if the implementation has to divide the result by a clock frequency, it could end up with a number that is not an integral number of picoseconds. Truncating toDiffTime
would lose precision, and that precision loss could add up, at least in theory.
SystemClock | |
|
Show (SystemClock time cumtime) |
Implementation(s)
The set of definitions below is platform-dependent.
systemClock_MONOTONIC :: SystemClock CTimeSpec DiffTimeSource
Uses clock_gettime
with CLOCK_MONOTONIC
.
Warning: on Linux, this clock stops when the computer is suspended. See http://lwn.net/Articles/434239/.