This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [patch libstdc++] Add POSIX variant of shared_timed_mutex.
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: Torvald Riegel <triegel at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, libstdc++ at gcc dot gnu dot org
- Date: Fri, 16 Jan 2015 13:18:08 +0000
- Subject: Re: [patch libstdc++] Add POSIX variant of shared_timed_mutex.
- Authentication-results: sourceware.org; auth=none
- References: <1421413979 dot 17929 dot 55 dot camel at triegel dot csb>
On 16/01/15 14:12 +0100, Torvald Riegel wrote:
[Resend. Sorry for the noise on gcc@.]
This adds a POSIX-based implementation of shared_timed_mutex, using
pthread_rwlock_* operations directly instead of implementing with
mutexes and two condvars. This enables using an optimized
pthread_rwlock_t on POSIX.
Tested on x86_64-linux.
OK?
OK for trunk - thanks.
diff --git a/libstdc++-v3/include/std/shared_mutex b/libstdc++-v3/include/std/shared_mutex
index 8bfede3..643768c 100644
--- a/libstdc++-v3/include/std/shared_mutex
+++ b/libstdc++-v3/include/std/shared_mutex
@@ -57,6 +57,188 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
/// shared_timed_mutex
class shared_timed_mutex
{
+#if defined(__GTHREADS_CXX0X)
N.B. I advised Torvald that this macro was OK to check that we have
pthread_rwlock_t available. It's not strictly correct, but currently
only gthr-posix.h defines __GTHREADS_CXX0X so it works in practice. We
should come up with something better at a later date though, or if any
other gthreads model ever supports C++11 threads.