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

Gábor Lehel illissius at gmail.com
Wed Jul 6 19:07:29 CEST 2011


2011/7/6 Donn Cave <donn at avvanta.com>:
> 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.

Hmm. That does seem like a pretty strong "disproof". I wonder if my
hypothesis is wrong in general, or if this particular library does in
fact have other requirements (thread-local storage or such) (and in
this case whether my other assumption was wrong and this is actually
the usual case), or if there's something else we're missing.

>
>        Donn
>



-- 
Work is punishment for failing to procrastinate effectively.



More information about the Haskell-Cafe mailing list