Skip to content

Commit e82d9e8

Browse files
committed
Move ConditionMutex to ConditionVariable::Mutex and move various other Mutex.h types to be nested.
1 parent dd6c235 commit e82d9e8

File tree

5 files changed

+386
-341
lines changed

5 files changed

+386
-341
lines changed

include/swift/Runtime/Concurrent.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,8 @@ template <class ElemTy> struct ConcurrentReadableArray {
508508
}
509509

510510
void push_back(const ElemTy &elem) {
511-
ScopedLock guard(WriterLock);
512-
511+
Mutex::ScopedLock guard(WriterLock);
512+
513513
auto *storage = Elements.load(std::memory_order_relaxed);
514514
auto count = storage ? storage->Count.load(std::memory_order_relaxed) : 0;
515515
if (count >= Capacity) {
@@ -594,9 +594,6 @@ struct ConcurrentReadableHashMap {
594594
"Elements must not have destructors (they won't be called).");
595595

596596
private:
597-
// A scoped lock type to use on MutexTy.
598-
using ScopedLockTy = ScopedLockT<MutexTy, false>;
599-
600597
/// The reciprocal of the load factor at which we expand the table. A value of
601598
/// 4 means that we resize at 1/4 = 75% load factor.
602599
static const size_t ResizeProportion = 4;
@@ -970,7 +967,7 @@ struct ConcurrentReadableHashMap {
970967
/// The return value is ignored when `created` is `false`.
971968
template <class KeyTy, typename Call>
972969
void getOrInsert(KeyTy key, const Call &call) {
973-
ScopedLockTy guard(WriterLock);
970+
typename MutexTy::ScopedLock guard(WriterLock);
974971

975972
auto *indices = Indices.load(std::memory_order_relaxed);
976973
if (!indices)
@@ -1022,7 +1019,7 @@ struct ConcurrentReadableHashMap {
10221019
/// Clear the hash table, freeing (when safe) all memory currently used for
10231020
/// indices and elements.
10241021
void clear() {
1025-
ScopedLockTy guard(WriterLock);
1022+
typename MutexTy::ScopedLock guard(WriterLock);
10261023

10271024
auto *indices = Indices.load(std::memory_order_relaxed);
10281025
auto *elements = Elements.load(std::memory_order_relaxed);

0 commit comments

Comments
 (0)