Remove the Upgrade lock stuff. (#221)

* Remove the `Upgrade` lock stuff.

* Need to repeat the `find()` if we released the mutex to get a write lock.

* Add a couple `assert`s.
This commit is contained in:
Gregory Popovitch
2023-11-29 13:16:09 -05:00
committed by GitHub
parent 7556c955d4
commit 4c93cf00f2
2 changed files with 15 additions and 24 deletions
+5 -3
View File
@@ -3465,12 +3465,14 @@ public:
auto hashval = this->hash(key);
Inner& inner = sets_[subidx(hashval)];
auto& set = inner.set_;
typename Lockable::UpgradeLock m(inner);
typename Lockable::ReadWriteLock m(inner);
auto it = set.find(key, hashval);
if (it == set.end())
return 0;
typename Lockable::UpgradeToUnique unique(m);
if (m.switch_to_unique()) {
it = set.find(key, hashval);
}
set._erase(it);
return 1;
}