On Mon, Nov 9, 2015 at 6:02 AM, Nicola Gigante <nicola.gigante@gmail.com> wrote:
Nothing actually, I was confused about what “unsafe” call means.

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.

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 (https://hackage.haskell.org/package/unagi-chan), 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.

Greg
--
Gregory Collins <greg@gregorycollins.net>