Re: Threads, gtk, pthreads, and gthreads



Soeren Sandmann wrote:

Gonzalo Aguilar <GAguilarDelgado terra es> writes:

Should I switch to gtk2 or should I wait?

I'd suggest switching to gtk2. It is much better than gtk1.

What about having 10-30 threads working for the main process in a gtk
app?
I know about 255 threads limit (pthreads) but with 10-30 GUI will be
slow, I think.

What do you need the threads for?

If you want to do some background processing and have your GUI update
at the same time, it is almost always better to g_idle_add() a
function to do the processing and then in that function do

        while (gtk_event_pending())
                gtk_main_iteration (FALSE);

to allow events to be processed.

But then I have to do it a lot of times and there are a lot of nested
events.
I tried to do this before but I switched to a threading model because
seems
more consistent.

Alternatively, if you really need to update the GUI from a thread, do
g_idle_add (function_that_does_the_updating, ...). In this case,
"function_that_does_the_updating" will be called from the thread that
runs the main loop, so it can safely call gtk functions.
What are you saying?
Can I use a function to do the update from a thread without using
gdk_locks?
So, if the function that updates the GUI is not a thread. Can It be
called safetly?
Even if it's called from a thread? No special requirements?

********************************

Threads are for processing incoming datagrams, so I have one for each
host
connected to me.

There is no need to do the g_idle_add as you say because gtk_main runs
on the
main thread (parent) which updates my GUI constantly because there are
no 
interruptions on the main thread.

Thanks.



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