- timeoutR :: (Integral i, Monad m, MonadRunnable m) => i -> m a -> RunData m -> IO (Maybe (m a))
- timeoutM :: (Integral i, Monad m, MonadIO m, MonadRunnable m) => i -> m a -> m (Maybe (m a))
- timeoutVoid :: (Integral i, Monad m, MonadIO m, MonadRunnable m) => i -> m () -> m Bool

# Documentation

timeoutR :: (Integral i, Monad m, MonadRunnable m) => i -> m a -> RunData m -> IO (Maybe (m a))Source

Run an action that is runnable in the IO monad within a time limit

The time limit is specified in microseconds, and is subject to the same sas `timeout`

.
Finally, the action to be run itself is passed. The result is an IO action, which is
normally lifted with `liftIO`

to be run in the same IO (see `timeoutM`

). The action,
when run, returns the resulting monadic value if it was run in time. Conceptually,
one can think of this as running a local monad, perhaps a copy, in the IO monad;
the effects of running in the IO monad are unavoidably irreversible, but the resulting monadic
value can be optionally ignored, in which case it is not evaluated in the parent monad
and no effects are present in the outer layers of the monad.

timeoutM :: (Integral i, Monad m, MonadIO m, MonadRunnable m) => i -> m a -> m (Maybe (m a))Source

Equivalent to `timeoutM`

, but the result is the same monad, making passing the data needed to run the monad unnecessary

timeoutVoid :: (Integral i, Monad m, MonadIO m, MonadRunnable m) => i -> m () -> m BoolSource

If the void action runs in time, it is run and `True`

is returned; otherwise `False`

is returned when running the action in time does not succeed

For example, to run a void action within one second, one might write

succeeded <- timeoutVoid

The effects of action will be fully executed if succeeded
is `True`

; if succeeded is `False`

, the action could not run
in time, and only global IO actions that were performed while
the local monad was being evaluated will be run.