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

Donn Cave donn at avvanta.com
Wed Jul 6 18:47:40 CEST 2011


Quoth =?ISO-8859-1?Q?G=E1bor_Lehel?= <illissius at gmail.com>,
...
> Stated another way: I suspect most GUI libraries don't really actually
> care that you only execute GUI code from the main OS thread, as much
> as they care that only one (thread-unsafe) GUI function is being
> called at any given time. If you only ever call GUI code from the same
> (main) OS thread, that fulfills this requirement, because an OS thread
> is only capable of running one library function at a time;
> alternately, if you only ever call GUI code from the same Haskell
> thread, that also fulfills this requirement, because one Haskell
> thread is also only capable of running one library function at a time,

I thought in the present case, the program now works when compiled,
but fails when run in GHCi, and we believe that the only difference
here is that GHCi took the main thread and put the program, and hence
the GUI, in some other thread?

I.e., your requirement is indeed met, per the second alternative,
but the program still fails, because this library really does need
to execute in the initial "main" program thread.

	Donn



More information about the Haskell-Cafe mailing list