Copyright | (c) 2021 Composewell Technologies |
---|---|
License | BSD-3-Clause |
Maintainer | streamly@composewell.com |
Stability | pre-release |
Portability | GHC |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- data Clock
- getTime :: Clock -> IO AbsTime
- asyncClock :: Clock -> Double -> IO (ThreadId, IORef MicroSecond64)
- readClock :: (ThreadId, IORef MicroSecond64) -> IO MicroSecond64
- data Timer
- timer :: Clock -> Double -> Double -> IO Timer
- resetTimer :: Timer -> IO ()
- extendTimer :: Timer -> Double -> IO ()
- shortenTimer :: Timer -> Double -> IO ()
- readTimer :: Timer -> IO Double
- waitTimer :: Timer -> IO ()
System clock
Clock types. A clock may be system-wide (that is, visible to all processes) or per-process (measuring time that is meaningful only within a process). All implementations shall support CLOCK_REALTIME. (The only suspend-aware monotonic is CLOCK_BOOTTIME on Linux.)
Monotonic | The identifier for the system-wide monotonic clock, which is defined as
a clock measuring real time, whose value cannot be set via
|
Realtime | The identifier of the system-wide clock measuring real time. For this
clock, the value returned by |
ProcessCPUTime | The identifier of the CPU-time clock associated with the calling
process. For this clock, the value returned by |
ThreadCPUTime | The identifier of the CPU-time clock associated with the calling OS
thread. For this clock, the value returned by |
MonotonicRaw | (since Linux 2.6.28; Linux and Mac OSX) Similar to CLOCK_MONOTONIC, but provides access to a raw hardware-based time that is not subject to NTP adjustments or the incremental adjustments performed by adjtime(3). |
MonotonicCoarse | (since Linux 2.6.32; Linux and Mac OSX) A faster but less precise version of CLOCK_MONOTONIC. Use when you need very fast, but not fine-grained timestamps. |
Uptime | (since Linux 2.6.39; Linux and Mac OSX) Identical to CLOCK_MONOTONIC, except it also includes any time that the system is suspended. This allows applications to get a suspend-aware monotonic clock without having to deal with the complications of CLOCK_REALTIME, which may have discontinuities if the time is changed using settimeofday(2). |
RealtimeCoarse | (since Linux 2.6.32; Linux-specific) A faster but less precise version of CLOCK_REALTIME. Use when you need very fast, but not fine-grained timestamps. |
Instances
Enum Clock Source # | |
Defined in Streamly.Internal.Data.Time.Clock.Type | |
Generic Clock Source # | |
Read Clock Source # | |
Show Clock Source # | |
Eq Clock Source # | |
type Rep Clock Source # | |
Defined in Streamly.Internal.Data.Time.Clock.Type type Rep Clock = D1 ('MetaData "Clock" "Streamly.Internal.Data.Time.Clock.Type" "streamly-0.8.3-7ePTR1H9Bp3FLh8wMmA1v5" 'False) (((C1 ('MetaCons "Monotonic" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "Realtime" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "ProcessCPUTime" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "ThreadCPUTime" 'PrefixI 'False) (U1 :: Type -> Type))) :+: ((C1 ('MetaCons "MonotonicRaw" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "MonotonicCoarse" 'PrefixI 'False) (U1 :: Type -> Type)) :+: (C1 ('MetaCons "Uptime" 'PrefixI 'False) (U1 :: Type -> Type) :+: C1 ('MetaCons "RealtimeCoarse" 'PrefixI 'False) (U1 :: Type -> Type)))) |
Async clock
asyncClock :: Clock -> Double -> IO (ThreadId, IORef MicroSecond64) Source #
asyncClock g
starts a clock thread that updates an IORef with current
time as a 64-bit value in microseconds, every g
seconds. The IORef can be
read asynchronously. The thread exits automatically when the reference to
the returned ThreadId
is lost.
Minimum granularity of clock update is 1 ms. Higher is better for performance.
CAUTION! This is safe only on a 64-bit machine. On a 32-bit machine a 64-bit
Var
cannot be read consistently without a lock while another thread is
writing to it.
readClock :: (ThreadId, IORef MicroSecond64) -> IO MicroSecond64 Source #
Adjustable Timer
timer :: Clock -> Double -> Double -> IO Timer Source #
timer clockType granularity period
creates a timer. The timer produces
timer ticks at specified time intervals that can be waited upon using
waitTimer
. If the previous tick is not yet processed, the new tick is
lost.
resetTimer :: Timer -> IO () Source #
Resets the current period.
extendTimer :: Timer -> Double -> IO () Source #
Elongates the current period by specified amount.
Unimplemented
shortenTimer :: Timer -> Double -> IO () Source #
Shortens the current period by specified amount.
Unimplemented