Time out

Simon Marlow simonmar@microsoft.com
Tue, 10 Sep 2002 14:17:41 +0100


> Ashley Yakeley wrote:
>=20
>  | >  timeOut :: Int -> IO a -> IO (Maybe a)
>  :
>  | Sounds rather unsafe. What happens to the IO action
>  | after the specified time?
>=20
> Good point. Actually, a function of the type:
>=20
>   timeOut :: Int -> a -> IO (Maybe a)
>=20
> would suffice for my purposes, but I tried to be a bit more
> general when I posed my question.

It's only unsafe if your code isn't written to cope with asynchronous
exceptions.  Doing this in most cases just amounts to using combinators
like Control.Exception.bracket to do the exception handling for you.  In
FFI code you have to be more careful, however.

Cheers,
	Simon