Re: Instabilities with multi threaded application

Since Philip is using pthreads and gthreads use pthreads (in linux,
which i am assuming is his platform), wouldn't a simple gthreads_init,

Also, if only one thread changes the gui is the
gdk_threads_{enter,leave} needed surrounding main_loop?

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?

I am also very interested in helping out in this issue, especially
because there are some issues that i think that need a bit more
explaining and/or examples.

Oh and one more thing, the glib documentation has a bug in
g_strsplit_set function's documentation:

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?

On Fri, 2004-07-23 at 15:43, Philip Van Hoof wrote:
> On Fri, 2004-07-23 at 10:39 -0400, Tristan Van Berkom wrote:
> > Philip Van Hoof wrote:
> > [...]
> > 
> >      "Unexpected async reply" means that the X server sent you
> > something your app was not prepared for, most often this means
> > that your thread has no associated GMainContext or is shareing the
> > same context as the parent thread (um, err, Its a little early after
> > a long night of gin so bear with me). Make sure you are calling
> > gdk_threads_init(); at the beginning of your program, and make
> > sure you use the gthread api (wich will use pthreads under linux),
> I thank you, Tristan
> I was unaware of a gthread API and was indeed using pthreads directly. I
> have ported all phtread functions to the gthread API and now things are
> actually stable and working.
> I am actually pretty amazed about this. The same code ran buggy as hell
> a few minutes ago, now it's as stable as I expected it to be.
> By that I mean that it works :)
> I must say, however, that most of the older mailinglist posts and Gtk+
> (> 2.0) documentation are very silent about the existence of this
> pthread API in glib. 
> My humble opinion is that we (or the documentation writers) should put
> an extra focus on this pthread API in the documentation and even more,
> the examples. 
> Maybe this is old documentation, but it's coming as first one when you
> do a search on google: "multi thread gtk+"
> The x462.html should clearly explain how to use the gthread API. I am
> willing to modify the sample if I am sure that the documentation will
> indeed get published on gnome (I dislike loosing time on getting stuff
> approved). 
> It's a sample that shows how to use the pthread API. It's not mentioning
> the gthread API. It would have saved me a few hours useless debugging if
> a better, more modern, sample would have come first on google.
> Nevertheless, thanks a lot. You saved my weekend. Really :). I can
> imagine myself debugging and coding all weekend long just to get this
> threading stuff right. Now my girlfriend will probably have her
> programmer all for herself in stead of behind his company laptop. Haha

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