This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [patch] Fix shared_timed_mutex::try_lock_until() et al
- From: Torvald Riegel <triegel at redhat dot com>
- To: Jonathan Wakely <jwakely at redhat dot com>
- Cc: libstdc++ at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Fri, 10 Apr 2015 02:16:06 +0200
- Subject: Re: [patch] Fix shared_timed_mutex::try_lock_until() et al
- Authentication-results: sourceware.org; auth=none
- References: <20150407142830 dot GG9755 at redhat dot com> <1428512373 dot 924 dot 26 dot camel at triegel dot csb> <20150408191159 dot GQ9755 at redhat dot com> <20150408193808 dot GR9755 at redhat dot com>
On Wed, 2015-04-08 at 20:38 +0100, Jonathan Wakely wrote:
> On 08/04/15 20:11 +0100, Jonathan Wakely wrote:
> >We can get rid of the _Mutex type then, and just use std::mutex, and
> >that also means we can provide the timed locking functions even when
> >!defined(_GTHREAD_USE_MUTEX_TIMEDLOCK).
> >
> >And so maybe we should use this fallback implementation instead of
> the
> >pthread_rwlock_t one when !defined(_GTHREAD_USE_MUTEX_TIMEDLOCK), so
> >that they have a complete std::shared_timed_mutex (this applies to at
> >least Darwin, not sure which other targets).
>
> Here's a further patch to do that (which really needs to go into 5.0
> too, so we don't switch Darwin to the new pthread_rwlock_t version and
> then have to swtich it back again in 6.0).
I understand why a mutex with timeouts isn't required anymore, but why
do you now add it to the USE_PTHREAD_RWLOCK_T condition? If
pthread_rwlock_t is available, why would we need a normal mutex with
timeouts?
For example, this chunk here (and others too):
> diff --git a/libstdc++-v3/include/std/shared_mutex b/libstdc
> ++-v3/include/std/shared_mutex
> index 7f26465..351a4f6 100644
> --- a/libstdc++-v3/include/std/shared_mutex
> +++ b/libstdc++-v3/include/std/shared_mutex
> @@ -57,7 +57,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> /// shared_timed_mutex
> class shared_timed_mutex
> {
> -#ifdef _GLIBCXX_USE_PTHREAD_RWLOCK_T
> +#if defined(_GLIBCXX_USE_PTHREAD_RWLOCK_T) &&
> _GTHREAD_USE_MUTEX_TIMEDLOCK
> typedef chrono::system_clock __clock_t;
>
> #ifdef PTHREAD_RWLOCK_INITIALIZER