
20 Jan
2004
20 Jan
'04
11:49 a.m.
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?
swapMVar is only atomic with respect to other well-behaved threads. By well-behaved I mean that they only do takeMVar followed by putMVar on the MVar, never a putMVar on its own. Does that answer your question? Cheers, Simon
7791
Age (days ago)
7791
Last active (days ago)
0 comments
1 participants
participants (1)
-
Simon Marlow