<div dir="ltr">What I'm doing is using STM (but it could be done with MVar instead) to guard access to a rotating queue that is a large mmapped region of memory (in my situation, it also happens to be backed by a file on disk). There can only be one writer at a time. There can be many readers, but the readers cannot read from the head of the queue if the writer is still working on it. They must wait until the writer is finished. So, every thread has the same base address and then they are all working at different offsets into the queue. But when the writer tries to tell the readers "I'm done writing to this area", how can I be sure that the readers will actually see the writes to memory? That's the difficulty I'm having.<br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jun 1, 2019 at 9:31 AM Elliot Cameron <<a href="mailto:eacameron@gmail.com">eacameron@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="auto">For my education, can you describe your use case a bit more? Using MVar as you did in your example seems like a strange use case. Normally you'd just put the pointer to the structure in the MVar itself.</div>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature">-Andrew Thaddeus Martin</div>