Safe Haskell | None |
---|---|
Language | Haskell2010 |
A typeclass for monads which can run actions with a time limit.
- data Timeout = Timeout
- class (Monad p, Monad m) => MonadTimeout m p where
- timeoutThrow :: TimeUnit t => t -> p a -> m a
- timeoutCatch :: TimeUnit t => t -> p a -> m (Maybe a)
Documentation
Timeout exception. Thrown when an action is executed with a time limit, and the time passes before the action finishes.
class (Monad p, Monad m) => MonadTimeout m p where Source
A class for monads capable of executing computations with a time limit. This class provides a uniform interface to the various possible implementations.
For example, a trivial implementation may launch a helper thread for each time-limited action. A more scalable implementation, preferred for some cases, may keep a single dedicated thread and reuse it instead of starting new ones.
timeoutThrow :: TimeUnit t => t -> p a -> m a Source
Execute an action with a time limit. If the action finishes before the
given time passes, return the value it returned. If the time passes and
the action hasn't finished yet, throw a Timeout
exception.
timeoutCatch :: TimeUnit t => t -> p a -> m (Maybe a) Source
(MonadIO m, MonadCatch m) => MonadTimeout (TimeoutT m) m Source |