8298: Stop using an upgradeable read lock in interning r=jonas-schievink a=jonas-schievink

Only one upgradeable read lock can be handed out at the same time, and
we never acquire a non-upgradeable read lock, so this has no benefit
over just using a write lock in the first place.

bors r+

Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
This commit is contained in:
bors[bot] 2021-04-02 18:47:25 +00:00 committed by GitHub
commit 8e3e13f3a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -25,7 +25,7 @@ impl<T: Internable> Interned<T> {
let storage = T::storage().get();
let shard_idx = storage.determine_map(&obj);
let shard = &storage.shards()[shard_idx];
let shard = shard.upgradeable_read();
let mut shard = shard.write();
// Atomically,
// - check if `obj` is already in the map
@ -43,10 +43,7 @@ impl<T: Internable> Interned<T> {
let arc = Arc::new(obj);
let arc2 = arc.clone();
{
let mut shard = shard.upgrade();
shard.insert(arc2, SharedValue::new(()));
}
Self { arc }
}