Safe Haskell | None |
---|---|
Language | Haskell2010 |
Utilities for repeatedly running
actions
at a specific frequency.IO
Frequencies are in Hertz; for example,
will run repeatedly
20 actact
20 times per second.
Synopsis
- repeatedly :: Rational -> IO a -> IO void
- repeatedly' :: Rational -> Clock -> IO a -> IO void
- asyncRepeatedly :: Rational -> IO a -> IO (Async void)
- asyncRepeatedly' :: Rational -> Clock -> IO a -> IO (Async void)
- data TimeStepClock
- newClock :: Rational -> Clock -> IO TimeStepClock
- loopUsing :: TimeStepClock -> IO a -> IO void
- module Time.Flick
- data Clock
Repeating actions
repeatedly :: Rational -> IO a -> IO void Source #
Run an action repeatedly at the specified frequency (in Hertz).
Uses the Monotonic
clock for timing.
repeatedly' :: Rational -> Clock -> IO a -> IO void Source #
Run an action repeatedly at the specified frequency (in Hertz), using the given clock type.
Repeating actions in another thread
asyncRepeatedly :: Rational -> IO a -> IO (Async void) Source #
Run an action repeatedly at the specified frequency (in Hertz), in a separate thread.
Uses the Monotonic
clock for timing.
asyncRepeatedly' :: Rational -> Clock -> IO a -> IO (Async void) Source #
Run an action repeatedly at the specified frequency (in Hertz), in a separate thread, using the given clock type.
Implementation details
data TimeStepClock Source #
Internal state of the stepper. Created using
.newClock
Instances
Eq TimeStepClock Source # | |
Defined in Time.Repeatedly (==) :: TimeStepClock -> TimeStepClock -> Bool # (/=) :: TimeStepClock -> TimeStepClock -> Bool # |
newClock :: Rational -> Clock -> IO TimeStepClock Source #
Initialise a new clock structure for the given frequency (in Hertz) and using the given clock type.
loopUsing :: TimeStepClock -> IO a -> IO void Source #
Repeat the given action using the information in the clock structure.
Reexports (timekeeping)
module Time.Flick
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-specific) 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). |
Boottime | (since Linux 2.6.39; Linux-specific) 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). |
MonotonicCoarse | (since Linux 2.6.32; Linux-specific) A faster but less precise version of CLOCK_MONOTONIC. Use when you need very fast, but not fine-grained timestamps. |
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 | |
Eq Clock | |
Read Clock | |
Show Clock | |
Generic Clock | |
type Rep Clock | |
Defined in System.Clock type Rep Clock = D1 (MetaData "Clock" "System.Clock" "clock-0.7.2-DpdvDKMysiO5fhuByT1Vyj" 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 "Boottime" PrefixI False) (U1 :: Type -> Type)) :+: (C1 (MetaCons "MonotonicCoarse" PrefixI False) (U1 :: Type -> Type) :+: C1 (MetaCons "RealtimeCoarse" PrefixI False) (U1 :: Type -> Type)))) |