std::shared_mutex support #11

This commit is contained in:
greg
2019-05-25 16:01:53 -04:00
parent ced6251124
commit 39c002d52a
2 changed files with 29 additions and 0 deletions
+25
View File
@@ -50,6 +50,10 @@
#include "phmap_config.h"
#ifdef PHMAP_HAVE_SHARED_MUTEX
#include <shared_mutex> // after "phmap_config.h"
#endif
namespace phmap {
template <class T> using Allocator = typename std::allocator<T>;
@@ -4898,6 +4902,27 @@ public:
};
#endif
// --------------------------------------------------------------------------
// std::shared_mutex support (read and write lock support)
// --------------------------------------------------------------------------
#ifdef PHMAP_HAVE_SHARED_MUTEX
// ---------------------------------------------------------------------------
template <>
class LockableImpl<std::shared_mutex> : public std::shared_mutex
{
public:
using mutex_type = std::shared_mutex;
using Base = LockableBaseImpl<std::shared_mutex>;
using SharedLock = std::shared_lock<mutex_type>;
using UpgradeLock = std::unique_lock<mutex_type>; // assume can't upgrade
using UniqueLock = std::unique_lock<mutex_type>;
using SharedLocks = typename Base::ReadLocks;
using UniqueLocks = typename Base::WriteLocks;
using UpgradeToUnique = typename Base::DoNothing; // we already have unique ownership
};
#endif
#endif // PHMAP_HAS_BOOST_THREAD_MUTEXES