System.SimpleTimeout
Description
Intended for internal use: Simple timeout mechanism
- data TimeoutHandle
- timeoutHandle :: Double -> IO TimeoutHandle
- timeout :: TimeoutHandle -> (Double -> IO a) -> IO a -> IO a
Documentation
data TimeoutHandle Source
Abstract data structure used by TimeoutHandle
and timeout
.
timeoutHandle :: Double -> IO TimeoutHandleSource
Creates a TimeoutHandle
.
The Double
parameter is the time limit in seconds.
All operations behind timeout
will be stopped
at the current time plus the time limit.
Arguments
:: TimeoutHandle | knows the time of the timeout and the creation time of itself |
-> (Double -> IO a) | timeout handling action for which will the percent will be supplied |
-> IO a | the operation to timeout |
-> IO a |
Stop an operation at a time given by timeoutHandle
.
The Double
parameter is a percent between 0 and 1.
- 0:
timeout
was called right after theTimeoutHandle
was created. - 1:
timeout
was called after the time of the timeout. - near to 1:
timeout
was called right before the time of the timeout. - Other values: proportional to the time spend by the operation.