
20 Jul
2005
20 Jul
'05
1:22 p.m.
On 2005-07-20, Simon Marlow
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