This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: recursive mutex?
In article <20011018155223.A28206@alinoe.com>,
Carlo Wood <carlo@alinoe.com> writes:
>> The gthr.h abstraction layer, which STL/libstdc++ uses, does not offer
>> a recursive mutex.
> In order to implement a recursive mutex, I will have to compare
> the thread-id with a stored version of itself. However, I also
> do not see support for a `pthread_self' and `pthread_equal' either.
It is true that the gthr.h abstraction layer is the least common
denominator of many known thread libraries. Thus, it doesn't have
many of the features you find missing.
> Does this mean I can not add a recursive mutex to libstdc++ without
> using Thread Specific Data? I'd rather solve it differently because
> it seems to me that getspecific is rather slow.
I admit that I don't know the optimal way to create a recursive mutex
abstraction from the non-recursive mutex. Surely, there is some way
to structure new code to allow the direct use of a non-recursive
mutex. Support for the recursive mutex was put in the standard to
allow one to wrap old interfaces more easily (according to
_Programming with POSIX Threads_ but I my experience matches the book).
Regards,
Loren