MVar swap

Georg Martius mai99dgf at studserv.uni-leipzig.de
Tue Jan 20 16:44:36 EST 2004


Hi,

I took a look at the implementation of the MVar function swap and I am 
just woundering where the atomicy comes from.

-- |Swap the contents of an 'MVar' for a new value.
swapMVar :: MVar a -> a -> IO a
swapMVar mvar new =
   block $ do
     old <- takeMVar mvar
     putMVar mvar new
     return old

Is it really just the Exception block, that makes it not interruptable?

Thanks!
Georg


More information about the Haskell-Cafe mailing list