Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Device for running an action at (i.e. shortly after) a certain time, which can be used to implement things like time-based cache expiry.
This implementation avoids the use of polling to achieve low-latency without lots of computational overhead.
The alarm can be set multiple times, and in this case the alarm action will run on the earliest such time. If the alarm is set in the past, the action will run immediately. When the action runs, it clears all future alarms; the action can itself return the time at which it should run again.
- data AlarmClock = AlarmClock (MVar UTCTime) ThreadId
- mkAlarmClock :: IO (Maybe UTCTime) -> IO AlarmClock
- destroyAlarmClock :: AlarmClock -> IO ()
- setAlarmVar :: MVar UTCTime -> UTCTime -> IO ()
- setAlarm :: AlarmClock -> UTCTime -> IO ()
- runAlarmClock :: MVar UTCTime -> IO () -> IO ()
Documentation
data AlarmClock Source
An AlarmClock
is a device for running an action at (or shortly after) a certain time.
mkAlarmClock :: IO (Maybe UTCTime) -> IO AlarmClock Source
destroyAlarmClock :: AlarmClock -> IO () Source
setAlarm :: AlarmClock -> UTCTime -> IO () Source