Portability | portable |
---|---|
Stability | provisional |
Maintainer | sabel@ki.cs.uni-frankfurt.de; willig@ki.cs.uni-frankfurt.de |
This module implements explicit futures (EFuture
, efuture
, force
) as well as several variants of implicit futures
(future
, recursiveFuture
, strictFuture
, strictRecursiveFuture
, lazyFuture
, lazyRecursiveFuture
)
While explicit futures must be forced (using force
) if their value is needed, this is not necessary for implicit futures.
For implicit futures it is necessary to put them into the global wrapper withFuturesDo
.
- type EFuture a = MVar a
- efuture :: IO a -> IO (EFuture a)
- force :: EFuture a -> IO a
- future :: IO a -> IO a
- recursiveFuture :: (a -> IO a) -> IO a
- withFuturesDo :: IO () -> IO ()
- strictFuture :: IO a -> IO a
- strictRecursiveFuture :: (a -> IO a) -> IO a
- lazyFuture :: IO a -> IO a
- lazyRecursiveFuture :: (a -> IO a) -> IO a
- hbind :: (t -> t1) -> t -> t1
- newhandled :: IO (a -> IO (), a)
- bhandle :: (a -> (a -> IO ()) -> t) -> IO t
Documentation
future
creates an implicit future. A non-blocking concurrent computation is started. If the value of the future is needed, then
the future will be forced implicitly. The concurrent computation is killed if the calling thread stops, even if future
is used
within withFuturesDo
.
recursiveFuture :: (a -> IO a) -> IO aSource
recursiveFuture
behaves similar to future
with the difference that the future is recursive, i.e. the future created by
recursiveFuture
is used as argument of the code of the future.
withFuturesDo :: IO () -> IO ()Source
withFuturesDo
is the global wrapper which should be used around the code involving futures.
I.e., instead of writing main=code
one should use main=withFuturesDo code
. Note, that there
should be only one call to withFuturesDo
in a program.
strictFuture :: IO a -> IO aSource
creating a strict future is similar to future
with the difference that if used inside withFuturesDo
it is guaranteed that the concurrent computation is forced (and finished) before the main thread terminates.
Warning: strictFuture
should only be used within the global wrapper withFuturesDo
!
strictRecursiveFuture :: (a -> IO a) -> IO aSource
a recursive variant of strictFuture
(see recursiveFuture
and 'future)
Warning: strictRecursiveFuture
should only be used within the global wrapper withFuturesDo
!
lazyFuture :: IO a -> IO aSource
a lazy future. Initially, no concurrent computation is started, but if the lazy future gets (implicitly) forced,
then the lazy future becomes a strict future.
Warning: lazyFuture
should only be used within the global wrapper withFuturesDo
!
lazyRecursiveFuture :: (a -> IO a) -> IO aSource
a recursive variant of lazyFuture
(see recursiveFuture
and 'future)
Warning: lazyRecursiveFuture
should only be used within the global wrapper withFuturesDo
!
newhandled :: IO (a -> IO (), a)Source
creates a new handle.