
2 Jul
2004
2 Jul
'04
9:59 a.m.
at a guess the magic take put is:
block ( do a <- takeMVar x putMVar x a ) return a
This doesn't prevent the race condition Conor mentioned. It only prevents the thread executing the above code from being interrupted by an asynchronous exception (i.e., Control-C, or another thread killing this one). The only way to prevents race conditions is through discipline (take then put is one example). A good way to enforce this discipline is to use withX-style combinators, and treat the put/take group of operations as primitives. A