<div class="gmail_quote">On Tue, Oct 25, 2011 at 10:47 AM, Ben Franksen <span dir="ltr">&lt;<a href="mailto:ben.franksen@online.de">ben.franksen@online.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
The main question is: does the STM transaction actually &quot;see&quot; that I changed</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
part of the underlying array, so that the transaction gets re-tried? Or do I<br>
have to implement this manually, and if yes: how?<br></blockquote><div><br></div><div>Create an extra TVar Int for every `chunk` in the array (e.g every 256 elements, tuned to your update patterns). Read-write it (increment it, be sure to force evaluation) just before every time you write an element or slice it or slice the array element. The IO mutable array is then adjusted unsafely, but there is enough transactional context to restart transactions that see an inconsistent state. You will have extra read/write and write/write conflicts relative to a pure STM solution, but only within each chunk.</div>
<div><br></div><div>A cleaner alternative is to create a `chunked` TArray, i.e. that works with fixed-width immutable chunks in a spine. This should have good performance characteristics, and would be a lot safer for general purpose use. </div>
<div> </div><div>Regards,</div><div><br></div><div>Dave</div></div>