POSIX clocks and timers.
- newtype Clock = Clock Int32
- monotonicClock :: Clock
- realtimeClock :: Clock
- processTimeClock :: Clock
- threadTimeClock :: Clock
- getProcClock :: ProcessID -> IO Clock
- getClockResolution :: Clock -> IO TimeSpec
- getClockTime :: Clock -> IO TimeSpec
- setClockTime :: Clock -> TimeSpec -> IO ()
- clockSleep :: Clock -> TimeSpec -> IO TimeSpec
- clockSleepAbs :: Clock -> TimeSpec -> IO ()
- data TimeSpec
- timeSpecSeconds :: TimeSpec -> CTime
- timeSpecNanoseconds :: TimeSpec -> CULong
- mkTimeSpec :: CTime -> CULong -> TimeSpec
- timeSpecV :: TimeSpec -> (CTime, CULong)
- data ITimerSpec = ITimerSpec {}
- data Timer
- createTimer :: Clock -> Maybe (Signal, WordPtr) -> IO Timer
- configureTimer :: Timer -> Bool -> TimeSpec -> TimeSpec -> IO (TimeSpec, TimeSpec)
- timerTimeLeft :: Timer -> IO (TimeSpec, TimeSpec)
- timerOverrunCnt :: Timer -> IO CInt
- destroyTimer :: Timer -> IO ()
Clocks
getProcClock :: ProcessID -> IO ClockSource
Get the CPU-time clock of the given process. See clock_getcpuclockid(3).
getClockResolution :: Clock -> IO TimeSpecSource
Get the clock resolution. See clock_getres(3).
getClockTime :: Clock -> IO TimeSpecSource
Get the clock time. See clock_gettime(3).
clockSleep :: Clock -> TimeSpec -> IO TimeSpecSource
Sleep for the specified duration. When interrupted by a signal, returns the amount of time left to sleep. See clock_nanosleep(3).
clockSleepAbs :: Clock -> TimeSpec -> IO ()Source
Sleep until the clock time reaches the specified value. See clock_nanosleep(3).
Timers
Mirrors struct timespec.
mkTimeSpec :: CTime -> CULong -> TimeSpecSource
Create a TimeSpec
from amounts of seconds and nanoseconds.
timeSpecV :: TimeSpec -> (CTime, CULong)Source
Convert a TimeSpec
to a pair of its components.
Useful as a view pattern.
data ITimerSpec Source
Mirrors struct itimerspec.
:: Clock | |
-> Maybe (Signal, WordPtr) | Optional signal to raise on timer expirations and value of siginfo.si_value. |
-> IO Timer |
Create a timer. See timer_create(3).
:: Timer | |
-> Bool | Whether the expiration time is absolute. |
-> TimeSpec | Expiration time. Zero value disarms the timer. |
-> TimeSpec | Interval between subsequent expirations. |
-> IO (TimeSpec, TimeSpec) |
Setup the timer. See timer_settime(3).
timerTimeLeft :: Timer -> IO (TimeSpec, TimeSpec)Source
Get the amount of time left until the next expiration and the interval between the subsequent expirations. See timer_gettime(3).
timerOverrunCnt :: Timer -> IO CIntSource
Get the timer overrun count. See timer_getoverrun(3).
destroyTimer :: Timer -> IO ()Source
Destroy the timer. See timer_delete(3).