Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Call TryGetValue in overload of ConcurrentDictionary.GetOrAdd to avoid acquiring lock #63

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,10 @@ public TValue GetOrAdd(TKey key, TValue value)
if (key == null) throw new ArgumentNullException("key");

TValue resultingValue;
if (TryGetValue(key, out resultingValue))
{
return resultingValue;
}
TryAddInternal(key, value, false, true, out resultingValue);
return resultingValue;
}
Expand Down