<div><div><div class="gmail_quote">If you have two streams of time/value pairs - using MVars as write-once sampling variables - and both streams are fed from another thread (e.g. timers firing), and you want to merge these two streams into a single stream with monotonic time stamps, then you want to be able to check if at time t an occurrence exists in a stream. In the case an old time was read but not yet written to an mvar, this could lead to the merged stream not being monotonic. At least in my C# prototype that was the case, I used many very high frequency timers to stress test the merger, and this bug popped up. I found similar code in the Reactive library, but Reactive is much more clever operationally (and semantically) than my little prototype so it might not be a problem. But if it is, I guess it can be solved by introducing another MVar to indicate "I'm reading time", at least I solved it in the C# prototype in that way. </div>
<div class="gmail_quote"><br></div><div class="gmail_quote"><br></div><div class="gmail_quote">On Sat, Feb 14, 2009 at 8:01 PM, Paul Johnson <span dir="ltr"><<a href="mailto:paul@cogito.org.uk">paul@cogito.org.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div><div></div><div class="Wj3C7c">I'm not entirely sure what you are trying to achieve here. Presumably you want v to contain the (value, time) pair as soon as possible after time "t". Of course it won't be instantaneous. So another thread could observe that at time (t+delta) the variable "v" does not yet contain (x,t). Is this a problem?<br>
</div></div>
<br>
Atomic transactions won't work because "getCurrentTime" is of type "IO Time", whereas anything inside "atomic" has to be of type "STM a".<br>
<br>
In theory you could lock out context switches by messing around with the GHC runtime, but if you are running on a multicore machine then that won't work either.<br><font color="#888888">
<br>
Paul.<br>
<br>
</font></blockquote></div><br></div></div>