Skip to content
Snippets Groups Projects
Commit e9e111d7 authored by Simon Marlow's avatar Simon Marlow
Browse files

[project @ 2000-10-02 11:06:19 by simonmar]

- move readMVar and swapMVar from PrelConc to concurrent

- add the following exception-safe MVar operations:

	withMVar    :: MVar a -> (a -> IO b) -> IO b
	modifyMVar  :: MVar a -> (a -> IO (a,b)) -> IO b
	modifyMVar_ :: MVar a -> (a -> IO a) -> IO ()

- re-implement readMVar and swapMVar in an exception-safe way.

- re-implement the Chan operations using withMVar et al.
parent 334e3c04
No related branches found
No related tags found
No related merge requests found
% -----------------------------------------------------------------------------
% $Id: PrelConc.lhs,v 1.20 2000/07/07 11:03:58 simonmar Exp $
% $Id: PrelConc.lhs,v 1.21 2000/10/02 11:06:19 simonmar Exp $
%
% (c) The University of Glasgow, 1994-2000
%
......@@ -33,8 +33,6 @@ module PrelConc
, newEmptyMVar -- :: IO (MVar a)
, takeMVar -- :: MVar a -> IO a
, putMVar -- :: MVar a -> a -> IO ()
, readMVar -- :: MVar a -> IO a
, swapMVar -- :: MVar a -> a -> IO a
, tryTakeMVar -- :: MVar a -> IO (Maybe a)
, isEmptyMVar -- :: MVar a -> IO Bool
......@@ -136,18 +134,6 @@ newMVar value =
putMVar mvar value >>
return mvar
readMVar :: MVar a -> IO a
readMVar mvar =
takeMVar mvar >>= \ value ->
putMVar mvar value >>
return value
swapMVar :: MVar a -> a -> IO a
swapMVar mvar new =
takeMVar mvar >>= \ old ->
putMVar mvar new >>
return old
-- tryTakeMVar is a non-blocking takeMVar
tryTakeMVar :: MVar a -> IO (Maybe a)
tryTakeMVar (MVar m) = IO $ \ s ->
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment