Proposal: To add 2 new lower-level concurrency constructs and rebuild Concurrent.Chan using them
wren ng thornton
wren at freegeek.org
Tue May 8 03:20:19 CEST 2012
On 5/7/12 11:25 AM, Ivan Tomac wrote:
> One assumption that has been made is that IORef reads and writes are
> atomic. In other words that if there are two or more concurrent writes
> to the same IORef, one of them will successfully write its data to it.
> I have not been able to find exact semantics of IORefs though I've
> asked in #haskell and others have suggested that the assumption is
> valid.
I'm sure reads and writes are atomic (for safety reasons), though I
don't know if that's formally specified anywhere. It should be though.
If you're paranoid, you can always use atomicModifyIORef which
guarantees atomicity. Albeit, that's more powerful (and hence slower)
than you need for plain reads and writes.
--
Live well,
~wren
More information about the Libraries
mailing list