[Haskell-cafe] STM atomic blocks in IO functions

Ketil Malde ketil at malde.org
Sat Jan 14 15:55:16 CET 2012


"Bryan O'Sullivan" <bos at serpentine.com> writes:

>> The question is a simple one. Must all operations on a TVar happen
>> within *the same* atomically block, or am I am I guaranteed thread
>> safety if, say, I have a number of atomically blocks in an IO
>> function.

> If you want successive operations to see a consistent state, they must
> occur in the same atomically block.

I'm not sure I understand the question, nor the answer?  I thought the
idea was that state should be consistent on the entry and exit of each
"atomically" block.  So you can break your program into multiple
transactions, but each transaction should be a semantically complete
unit.

-k
-- 
If I haven't seen further, it is by standing in the footprints of giants



More information about the Haskell-Cafe mailing list