putMVar m a
return a
--- |Swap the contents of an 'MVar' for a new value.
+{-|
+ Take a value from an 'MVar', put a new value into the 'MVar' and
+ return the value taken. Note that there is a race condition whereby
+ another process can put something in the 'MVar' after the take
+ happens but before the put does.
+-}
swapMVar :: MVar a -> a -> IO a
swapMVar mvar new =
block $ do