diff options
author | Zachary Turner <zturner@google.com> | 2014-06-17 00:17:38 +0000 |
---|---|---|
committer | Zachary Turner <zturner@google.com> | 2014-06-17 00:17:38 +0000 |
commit | 84fea7720cf37d82af2968e073cff71305f130e7 (patch) | |
tree | 450b3bb3b89ad6f5478868f29037e8a2ad443495 /include/llvm | |
parent | 408691f9673fb69b5ed45326f6ded4f3b6f19c50 (diff) | |
download | llvm-84fea7720cf37d82af2968e073cff71305f130e7.tar.gz llvm-84fea7720cf37d82af2968e073cff71305f130e7.tar.bz2 llvm-84fea7720cf37d82af2968e073cff71305f130e7.tar.xz |
Expose ValueMap's mutex type as a typedef instead of a sys::Mutex.
This enables static polymorphism of the mutex type, which is
necessary in order to replace the standard mutex implementation
with a different type.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211080 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/IR/ValueMap.h | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/include/llvm/IR/ValueMap.h b/include/llvm/IR/ValueMap.h index 1503aed621..f196f334b6 100644 --- a/include/llvm/IR/ValueMap.h +++ b/include/llvm/IR/ValueMap.h @@ -45,8 +45,10 @@ class ValueMapConstIterator; /// This class defines the default behavior for configurable aspects of /// ValueMap<>. User Configs should inherit from this class to be as compatible /// as possible with future versions of ValueMap. -template<typename KeyT> +template<typename KeyT, typename MutexT = sys::Mutex> struct ValueMapConfig { + typedef MutexT mutex_type; + /// If FollowRAUW is true, the ValueMap will update mappings on RAUW. If it's /// false, the ValueMap will leave the original mapping in place. enum { FollowRAUW = true }; @@ -67,7 +69,7 @@ struct ValueMapConfig { /// and onDelete) and not inside other ValueMap methods. NULL means that no /// mutex is necessary. template<typename ExtraDataT> - static sys::Mutex *getMutex(const ExtraDataT &/*Data*/) { return nullptr; } + static mutex_type *getMutex(const ExtraDataT &/*Data*/) { return nullptr; } }; /// See the file comment. @@ -212,7 +214,7 @@ public: void deleted() override { // Make a copy that won't get changed even when *this is destroyed. ValueMapCallbackVH Copy(*this); - sys::Mutex *M = Config::getMutex(Copy.Map->Data); + typename Config::mutex_type *M = Config::getMutex(Copy.Map->Data); if (M) M->acquire(); Config::onDelete(Copy.Map->Data, Copy.Unwrap()); // May destroy *this. @@ -225,7 +227,7 @@ public: "Invalid RAUW on key of ValueMap<>"); // Make a copy that won't get changed even when *this is destroyed. ValueMapCallbackVH Copy(*this); - sys::Mutex *M = Config::getMutex(Copy.Map->Data); + typename Config::mutex_type *M = Config::getMutex(Copy.Map->Data); if (M) M->acquire(); |