Re: Instabilities with multi threaded application



Tiago Cogumbreiro <cogumbreiro linus uac pt> writes:

> Since Philip is using pthreads and gthreads use pthreads (in linux,
> which i am assuming is his platform), wouldn't a simple gthreads_init,
> suffice? 
> 
> Also, if only one thread changes the gui is the
> gdk_threads_{enter,leave} needed surrounding main_loop?

No.

> Are g_{idle,timeout}_add add thread safe? Can i call them from another
> problems with no problems whatsoever? I'm am routing all my gui related
> tasks to these functions and therefore skiping the gdk lock, is this an
> acceptable procedure?

Yes, calling g_idle/timeout_add from another thread is perfectly
legal. Those functions will do their own locking, so
gdk_threads_enter/leave() are no not needed. And yes, routing all gui
related tasks though those functions is acceptable and what I'd
usually recommend for using threads with GTK+.

There is no need for gdk_threads_enter/leave() in the callbacks either
since they will be called from the main gtk+ thread. Of course, if the
callbacks are accessing data structures that are modified by other
threads, then locking will be needed,

> Oh and one more thing, the glib documentation has a bug in
> g_strsplit_set function's documentation:
> 
> http://developer.gnome.org/doc/API/2.0/glib/glib-String-Utility-Functions.html#g-strsplit-set
> 
> I'm assuming this function came from somewhere else and had the name
> g_strtokenize, it should be g_strsplit_set. Should i fill a bug report
> about this?

Yes, filing a bug at

        http://bugzilla.gnome.org/enter_bug.cgi

is the thing to do, but I'll just go ahead and fix this one. Thanks.



Søren



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