Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module defines a Promise
type, represents a value which is not yet
available, and related utilities.
Synopsis
- data Promise a
- data Fulfiller a
- newPromise :: MonadIO m => m (Promise a, Fulfiller a)
- newPromiseSTM :: STM (Promise a, Fulfiller a)
- newPromiseWithCallback :: MonadIO m => (Either Exception a -> STM ()) -> m (Promise a, Fulfiller a)
- newPromiseWithCallbackSTM :: (Either Exception a -> STM ()) -> STM (Promise a, Fulfiller a)
- newCallback :: MonadIO m => (Either Exception a -> STM ()) -> m (Fulfiller a)
- newCallbackSTM :: (Either Exception a -> STM ()) -> STM (Fulfiller a)
- fulfill :: MonadIO m => Fulfiller a -> a -> m ()
- fulfillSTM :: Fulfiller a -> a -> STM ()
- breakPromise :: MonadIO m => Fulfiller a -> Exception -> m ()
- breakPromiseSTM :: Fulfiller a -> Exception -> STM ()
- data ErrAlreadyResolved = ErrAlreadyResolved
- wait :: MonadIO m => Promise a -> m a
- waitSTM :: Promise a -> STM a
Documentation
A promise is a value that may not be ready yet.
Creating promises
newPromise :: MonadIO m => m (Promise a, Fulfiller a) Source #
Create a new promise and an associated fulfiller.
newPromiseSTM :: STM (Promise a, Fulfiller a) Source #
Like newPromise
, but in STM
.
newPromiseWithCallback :: MonadIO m => (Either Exception a -> STM ()) -> m (Promise a, Fulfiller a) Source #
Create a new promise which also excecutes an STM action when it is resolved.
newPromiseWithCallbackSTM :: (Either Exception a -> STM ()) -> STM (Promise a, Fulfiller a) Source #
Like newPromiseWithCallbackSTM
, but runs in STM
.
newCallback :: MonadIO m => (Either Exception a -> STM ()) -> m (Fulfiller a) Source #
Like newPromiseWithCallback
, but doesn't return the promise.
newCallbackSTM :: (Either Exception a -> STM ()) -> STM (Fulfiller a) Source #
Like newCallback
, but runs in STM
.
Fulfilling or breaking promises
fulfill :: MonadIO m => Fulfiller a -> a -> m () Source #
Fulfill a promise by supplying the specified value. It is an error to
call fulfill
if the promise has already been fulfilled (or broken).
breakPromise :: MonadIO m => Fulfiller a -> Exception -> m () Source #
Break a promise. When the user of the promise executes wait
, the
specified exception will be raised. It is an error to call breakPromise
if the promise has already been fulfilled (or broken).
breakPromiseSTM :: Fulfiller a -> Exception -> STM () Source #
Like breakPromise
, but in STM
.
data ErrAlreadyResolved Source #
An exception thrown if breakPromise
or fulfill
is called on an
already-resolved fulfiller.
Instances
Show ErrAlreadyResolved Source # | |
Defined in Capnp.Rpc.Promise showsPrec :: Int -> ErrAlreadyResolved -> ShowS # show :: ErrAlreadyResolved -> String # showList :: [ErrAlreadyResolved] -> ShowS # | |
Exception ErrAlreadyResolved Source # | |
Defined in Capnp.Rpc.Promise |