<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Nov 9, 2015 at 6:02 AM, Nicola Gigante <span dir="ltr"><<a href="mailto:nicola.gigante@gmail.com" target="_blank">nicola.gigante@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Nothing actually, I was confused about what “unsafe” call means.</blockquote></div><br>In fact, as you've probably realized, the reason these calls are labeled unsafe is precisely because they don't yield the capability. An unsafe FFI call that blocks will block the Haskell capability -- this not only starves that CPU for actual work, it will eventually block the whole program once the RTS tries to do a round of stop-the-world GC.</div><div class="gmail_extra"><br clear="all"><div>As Edward pointed out, you're better off just relying on the concurrency primitives Haskell already gives you unless you find they're too slow. Another thing you can try is the unagi-chan library on Hackage (<a href="https://hackage.haskell.org/package/unagi-chan">https://hackage.haskell.org/package/unagi-chan</a>), which offers versions of blocking and non-blocking producer-consumer queues that claim to be much faster than the ones that come with the standard library.</div><div><br></div><div>Greg</div>-- <br><div class="gmail_signature">Gregory Collins <<a href="mailto:greg@gregorycollins.net" target="_blank">greg@gregorycollins.net</a>></div>
</div></div>