<div dir="ltr">  Hi Erik,<div><br></div><div>there seem to be several options. Tie simplest one is that you&#39;ll call getEvent with some reasonable timeout in a loop and check some communication channel an update from the calculation thread.</div>

<div><br></div><div style>Probably the correct way how to handle it involves three threads:</div><div style>(1) The computation thread writes its updates to a channel of type Either Event ComputationUpdate using Right.</div>

<div style>(2) Another thread calls getEvent repeatedly and writes received events to the channel using Left.</div><div style>(3) A consuming thread (the one for Ncurses UI) consumes the channel and reacts both to computation updates and Ncurses events.</div>

<div style><br></div><div style>However, I&#39;m not sure if Ncurses doesn&#39;t mind calling getEvent from a different thread than the one that updates UI.</div><div style><br></div><div style>For the communication channel, I&#39;d probably use TQueue (or TBQueue, if there is a risk of writing values too fast).</div>

<div style><br></div><div style>  Best regards,</div><div style>  Petr Pudlak</div><div style><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">2013/1/26 Erik de Castro Lopo <span dir="ltr">&lt;<a href="mailto:mle+hs@mega-nerd.com" target="_blank">mle+hs@mega-nerd.com</a>&gt;</span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
I am in the process of writing a Haskell program consisting of two<br>
threads, one for performing a calculation and one for an Ncurses UI<br>
(haskell-ncurses).<br>
<br>
The calculation thread needs to feed a stream of numbers back to the<br>
UI thread (about 1 value per second) and the UI needs to take input<br>
from the user and will pass parameter changes to the calculation<br>
thread using an IORef and atomicModifyIORef.<br>
<br>
However, I&#39;m not sure how to hande the UI thread. The UI thread would<br>
normally wait for Ncurses input using getEvent, but I need advice on<br>
how to the the data from the calculation thread.<br>
<br>
Any advice or things to try?<br>
<br>
Cheers,<br>
Erik<br>
<span class="HOEnZb"><font color="#888888">--<br>
----------------------------------------------------------------------<br>
Erik de Castro Lopo<br>
<a href="http://www.mega-nerd.com/" target="_blank">http://www.mega-nerd.com/</a><br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</font></span></blockquote></div><br></div>