Re: [gtk-list] Re: gdk_threads_enter is not reentrant

Sometimes you really do need to explicitly release a mutex no matter
what lock depth you're at.  To do so requires you know exactly how
many time gdk_threads_lock has been called.  Please at least put in a
gdk_threads_depth counter so users can do their own lock release.

Multithreaded programs really need to be able to do this, and it's
trivial to do, no matter what threads implementation you use.

    /* this is only valid after gdk_threads_enter() */
    int gdk_threads_depth = 0;

    gdk_threads_enter() {
	return ++gdk_threads_depth;

    gdk_threads_leave() {

    gdk_threads_leave_depth() {
        int i, depth;
	i = depth = gdk_threads_depth;
        while( i-- > 0 ) {   
	return depth;

    gdk_threads_enter_depth(int depth) {
        while( depth-- > 0 ) {   
	return gdk_threads_depth;


> Date: Mon, 13 Mar 2000 08:53:36 +0000
> From: Sebastian Wilhelmi <>
> Hi Noel,
> > Thanks Sebastian, I look forward to your changes.  One thing I should
> > mention: when you make gdk_threads_enter() reentrant, you should add
> > functions to release all locks no matter what depth you're at.
> > Consider this code:
> No, I don't think, you'll get that. As I'm going to use the native recursive
> implementation where available (Linux for example, but also Solaris 2.7; with
> a horrible broken implementation though, I wonder, how they managed to get
> that wrong), this is not possible.
> Bye,
> Sebastian

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