Portability | Tested on Linux and Windows. |
---|---|
Maintainer | joeyadams3.14159@gmail.com |
Safe Haskell | Safe-Infered |
This module provides a platform-independent API for using the system's monotonic clock.
Known issues:
- On Windows XP, this uses
GetTickCount
, which has a 49.7 day wraparound.Clock
works around this problem, but the workaround only works ifclockGetTime
is called at least once every 24.8 days. - On Linux, this uses
clock_gettime
withCLOCK_MONOTONIC
, which (unfortunately) stops when the computer is suspended. Thus,clockGetTime
will not include time spent sleeping. Do not rely on this behavior, as it may be fixed in a future version of this library.
- data Clock
- newClock :: IO Clock
- clockGetTime :: Clock -> IO DiffTime
- newClockWithDriver :: SomeSystemClock -> IO Clock
- clockDriverName :: Clock -> String
- delay :: DiffTime -> IO ()
Clock
Create a new Clock
. The result of clockGetTime
is based on the time
newClock
was called.
clockGetTime :: Clock -> IO DiffTimeSource
Return the amount of time that has elapsed since the clock was created
with newClock
.
Drivers
newClockWithDriver :: SomeSystemClock -> IO ClockSource
Variant of newClock
that uses the given driver. This can be used if you
want to use a different time source than the default.
newClock
=newClockWithDriver
=<<getSystemClock
clockDriverName :: Clock -> StringSource
Return a string identifying the time source, such as
"clock_gettime(CLOCK_MONOTONIC)"
or
"GetTickCount"
.