From: simonmar Date: Thu, 15 Feb 2001 10:02:43 +0000 (+0000) Subject: [project @ 2001-02-15 10:02:43 by simonmar] X-Git-Tag: Approximately_9120_patches~2620 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=956d36d236054aa1a71ef7ec15e80f6c7c4d10c8;p=ghc-hetmet.git [project @ 2001-02-15 10:02:43 by simonmar] changes to support tryPutMVar which I forgot in the main commit. --- diff --git a/ghc/lib/std/PrelConc.lhs b/ghc/lib/std/PrelConc.lhs index 0122dd8..32240b4 100644 --- a/ghc/lib/std/PrelConc.lhs +++ b/ghc/lib/std/PrelConc.lhs @@ -1,5 +1,5 @@ % ----------------------------------------------------------------------------- -% $Id: PrelConc.lhs,v 1.22 2001/02/13 15:23:33 rrt Exp $ +% $Id: PrelConc.lhs,v 1.23 2001/02/15 10:02:43 simonmar Exp $ % % (c) The University of Glasgow, 1994-2000 % @@ -34,13 +34,14 @@ module PrelConc , takeMVar -- :: MVar a -> IO a , putMVar -- :: MVar a -> a -> IO () , tryTakeMVar -- :: MVar a -> IO (Maybe a) + , tryPutMVar -- :: MVar a -> a -> IO Bool , isEmptyMVar -- :: MVar a -> IO Bool ) where import PrelBase import PrelMaybe -import PrelErr ( parError, seqError ) +import PrelErr ( parError, seqError ) import PrelIOBase ( IO(..), MVar(..) ) import PrelBase ( Int(..) ) import PrelException ( Exception(..), AsyncException(..) ) @@ -128,6 +129,12 @@ putMVar (MVar mvar#) x = IO $ \ s# -> case putMVar# mvar# x s# of s2# -> (# s2#, () #) +tryPutMVar :: MVar a -> a -> IO Bool +tryPutMVar (MVar mvar#) x = IO $ \ s# -> + case tryPutMVar# mvar# x s# of + (# s, 0# #) -> (# s, False #) + (# s, _ #) -> (# s, True #) + newMVar :: a -> IO (MVar a) newMVar value = newEmptyMVar >>= \ mvar ->