Re: [gtk-list] threading



Tom Stanis wrote:

> I want to be able to use multiple threads of execution in my gtk project,
> however, X is not ammused when one thread attempts to destroy and window,
> and the other is processing events.

Yes, most X libraries are not compiled to be thread-safe and even if they were,
their supporting libraries such as GTK, Motif, etc are not thread-safe.

> I thought I might be able to get
> around this problem using some sort of messaging, but the gtk thread (the one
> that handels all gtk work, in order to keep it non-concurrent), is stuck
> in the gtk_main(), so I can't do my own messaging, I have to use something that
> gtk can provide.  I looked at the gtk signals, but they seem to be created
> specifically for callbacks, and it seems rather cryptic how one might use them
> if you weren't writing a widget.  Anyone have any ideas on how to deal with
> this?  Can you use gtk signals for app level purposes?

One way to do what you want to to use gtk_input_add():  poke the GTK thread by
sending some data to a file descriptor registerd using gtk_input_add() which in
turn invokes a callback you could use to do the work you need the thread to do.

I am working now on just such a beast.  I am calling it a thread proxy.  I'll have
something available shortly.

$cott





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]