> The logical dual to tryTakeMVar would be
>    tryPutMVar :: MVar a -> a -> IO Bool

tryPutMVar :: MVar a -> a -> IO Bool
tryPutMVar m a
  = Exception.catchAllIO 
                (do { putMVar m a; return True })
                (\e -> case e of
                                PutFullMVar -> return False
                                _other      -> throw e)

> Or even
>    tryPutMVar :: MVar a -> IO a -> IO (Maybe a)
> (the latter only if you can keep the MVar empty while you run 
> the action.)

This one needs another lock, I guess.

Cheers,
        Simon

Reply via email to