On 2013-08-05 17:06, koral wrote:
> Is it normal that my program hangs forever when I call 'postGUISync'
> within the main gtk thread (notably in a callback triggered by a gtk
> signal) ?
Yes, I think it's normal. postGUISync is essentially: create a new MVar,
put something on the queue that executes your action and writes the
MVar, then take the MVar (immediately). Taking the MVar blocks the
current Haskell thread. Since the other actions won't run until the
current Haskell thread finishes running its callback, the action to fill
the MVar will never execute, so you're in trouble.
> I have written high level functions that may be called from any
> thread, including the main gtk one.
> Please tell me I don't have to tediously check from which thread those
> functions are called at runtime...
Sorry, but there's no easy answers for threading. You have to be
But why do you say that a runtime thread check is tedious? Perhaps your
high-level functions can just call myThreadID and dispatch to id or
postGUISync depending on whether the current thread is the main one or