[Haskell-cafe] Re: FFI and callbacks

John Goerzen jgoerzen at complete.org
Wed Jul 20 13:22:45 EDT 2005


On 2005-07-20, Simon Marlow <simonmar at microsoft.com> wrote:
> You could forkIO the main loop if you want; it shouldn't make any
> difference, except that GHC terminates the program when the main thread
> completes, so it's more convenient to have the main loop run in the main
> thread, so that the program terminates when the main loop returns.

Here's my concern.

I assume that, internally, forkIO is implemented using poll() or
select().  This obviously requires that all parts of the program
cooperate with this mechanism.  If this mainloop never returns (that is,
it blocks until the UI is destroyed), how do other forkIO'd threads ever
get a chance to run?

Assuming my program uses only forkIO threads, does the C library really
need to be thread-safe?

-- John



More information about the Haskell-Cafe mailing list