[Haskell-cafe] How to ensure code executes in the context of a specific OS thread?

David Barbour dmbarbour at gmail.com
Mon Jul 4 07:31:54 CEST 2011


On Jul 3, 2011, Jason Dagit <dagitj at gmail.com> wrote:

> to correctly handle GUI events you need to use the original thread
> allocated to your process to check for events and to call the Cocoa
> framework functionality.
>
> I looked at the threading documentation in Control.Concurrent for GHC and
> it's not clear to me if this is even possible with GHC without restricting
> to the non-threaded RTS.
>

The 'main' thread in GHC is the bound thread initially allocated to the
process. You can easily establish an event-loop in the main thread, and feed
events from other threads. Consider using Control.Concurrent.Chan.

If you need feedback, things get a bit trickier because you'll have special
cases based on whether you're starting in the main thread.

Regards,

Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20110703/1d45067d/attachment.htm>


More information about the Haskell-Cafe mailing list