Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Contains a simulated-time implementaion. It can be used directly,
to implement the simulated versions of getCurrentTime and
threadDelay, or can be used via monad transformers defined in
SimulatedTime
Synopsis
- data TimeEnv
- create :: UTCTime -> IO TimeEnv
- advance :: TimeEnv -> NominalDiffTime -> IO ()
- triggerEvents :: TimeEnv -> IO ()
- getSimulatedTime :: TimeEnv -> IO UTCTime
- threadDelay' :: TimeEnv -> Int -> IO ()
Documentation
It remembers the offset from system time and keeps a list of
sleeping threads (threads in threadDelay'
call)
create :: UTCTime -> IO TimeEnv Source #
Create the simulated time env from the given time start point. For example
timeEnv <- create (fromGregorian 2000 1 1) 0 getSimulatedTime timeEnv
triggerEvents :: TimeEnv -> IO () Source #
Wake up due sleeping threads, based on TimeEnv. This happens on
its own, but this call can quicken things up. Under the hood it is
just advance tenv 0
threadDelay' :: TimeEnv -> Int -> IO () Source #
Simulated alternative to threadDelay
, sleep
for the given number of microseconds. Threads wakes up according to
the simulated time.