diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2020-10-22 18:42:03 +0100 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2020-10-22 18:49:38 +0100 |
commit | f5d9bc8ae81abe46640477bc9e655aa093947f5f (patch) | |
tree | 156bfe87b2dae29d10602b2b63928fc73552eef8 /libstdc++-v3/include/std/shared_mutex | |
parent | b1e7c6fce15b8ad222f265df2537701407fd289e (diff) | |
download | gcc-f5d9bc8ae81abe46640477bc9e655aa093947f5f.zip gcc-f5d9bc8ae81abe46640477bc9e655aa093947f5f.tar.gz gcc-f5d9bc8ae81abe46640477bc9e655aa093947f5f.tar.bz2 |
libstdc++: Only include <condition_variable> in <shared_mutex> if needed
The <condition_variable> header is not small, so <shared_mutex> should
not include it unless it actually needs std::condition_variable, which
is only the case when we don't have pthread_rwlock_t and the POSIX
Timers option.
The <shared_mutex> header would be even smaller if we had a header for
std::condition_variable (separate from std::condition_variable_any).
That's already planned for a future change.
And <memory_resource> would be even smaller if it was possible to get
std::shared_mutex without std::shared_timed_mutex (which depends on
<chrono>). For that to be effective, the synchronized_pool_resource
would have to create its own simpler version of std::shared_lock without
the timed waiting functions. I have no plans to do that.
libstdc++-v3/ChangeLog:
* include/std/shared_mutex: Only include <condition_variable>
when pthread_rwlock_t and POSIX timers are not available.
(__cpp_lib_shared_mutex, __cpp_lib_shared_timed_mutex): Change
value to be type 'long'.
* include/std/version (__cpp_lib_shared_mutex)
(__cpp_lib_shared_timed_mutex): Likewise.
Diffstat (limited to 'libstdc++-v3/include/std/shared_mutex')
-rw-r--r-- | libstdc++-v3/include/std/shared_mutex | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/libstdc++-v3/include/std/shared_mutex b/libstdc++-v3/include/std/shared_mutex index 414dce3..7d683a0 100644 --- a/libstdc++-v3/include/std/shared_mutex +++ b/libstdc++-v3/include/std/shared_mutex @@ -33,9 +33,14 @@ #if __cplusplus >= 201402L -#include <bits/c++config.h> -#include <condition_variable> +#include <chrono> #include <bits/functexcept.h> +#include <bits/move.h> // move, __exchange +#include <bits/std_mutex.h> // defer_lock_t + +#if ! (_GLIBCXX_USE_PTHREAD_RWLOCK_T && _GTHREAD_USE_MUTEX_TIMEDLOCK) +# include <condition_variable> +#endif namespace std _GLIBCXX_VISIBILITY(default) { @@ -49,11 +54,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #ifdef _GLIBCXX_HAS_GTHREADS #if __cplusplus >= 201703L -#define __cpp_lib_shared_mutex 201505 +#define __cpp_lib_shared_mutex 201505L class shared_mutex; #endif -#define __cpp_lib_shared_timed_mutex 201402 +#define __cpp_lib_shared_timed_mutex 201402L class shared_timed_mutex; /// @cond undocumented @@ -399,7 +404,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif /// @endcond -#if __cplusplus > 201402L +#if __cplusplus >= 201703L /// The standard shared mutex type. class shared_mutex { @@ -814,7 +819,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION release() noexcept { _M_owns = false; - return std::exchange(_M_pm, nullptr); + return std::__exchange(_M_pm, nullptr); } // Getters |