Re: multi-threaded apps.



On Mon, 21 Aug 2000, Ian Campbell wrote:

> 
> 
> Thanks to all those who gave answer earlier.
> 
> I have one more question:
> 
> The mutex used by gdk_threads_{enter/leave} does not appear to have been
> created as a recursive mutex (ie I can't take the lock twice from the same
> thread).

I can't remember if they included recursive locks in glib-1.2.

> 
> So my problem is that a function which takes the gdk lock may be called from a
> callback (which has the lock held already) or from a thread (which doesn't
> hold
> the lock), how do I know if I need to take the lock - I don't think there is
> any way..

Just put some note at the top of the callback stating that it expects to
have the lock when called, and acquire the lock in your other thread
before calling it there.

> 
> So, it looks to me like it is not possible to make a MT safe GTK+ object
> (which
> to be fair some people have said before...)
> 
> Any clues/hints?

James.

-- 
Email: james@daa.com.au
WWW:   http://www.daa.com.au/~james/







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