mirror of
https://github.com/greg7mdp/parallel-hashmap.git
synced 2026-08-29 16:40:39 +08:00
std::shared_mutex support #11
This commit is contained in:
Vendored
+25
@@ -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
|
||||
|
||||
|
||||
|
||||
Vendored
+4
@@ -311,6 +311,10 @@
|
||||
#define PHMAP_HAVE_STD_STRING_VIEW 1
|
||||
#endif
|
||||
|
||||
#if (defined(_MSVC_LANG) && _MSVC_LANG >= 201402) || __cplusplus >= 201402
|
||||
#define PHMAP_HAVE_SHARED_MUTEX 1
|
||||
#endif
|
||||
|
||||
#ifndef PHMAP_HAVE_STD_STRING_VIEW
|
||||
#define PHMAP_HAVE_STD_STRING_VIEW 0
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user