Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Used ConcurrentDictionary in the not ThreadSafeDictionary #1

Merged
merged 1 commit into from
Dec 6, 2020
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Octokit/Octokit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Description>An async-based GitHub API client library for .NET and .NET Core</Description>
<AssemblyTitle>Octokit</AssemblyTitle>
<Authors>GitHub</Authors>
<Version>1.0.0</Version>
<Version>1.0.1</Version>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>Octokit</AssemblyName>
<PackageId>Apiiro.Octokit</PackageId>
Expand Down
7 changes: 4 additions & 3 deletions Octokit/SimpleJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
Expand Down Expand Up @@ -2122,7 +2123,7 @@ public sealed class ThreadSafeDictionary<TKey, TValue> : IDictionary<TKey, TValu
{
private readonly object _lock = new object();
private readonly ThreadSafeDictionaryValueFactory<TKey, TValue> _valueFactory;
private Dictionary<TKey, TValue> _dictionary;
private ConcurrentDictionary<TKey, TValue> _dictionary;

public ThreadSafeDictionary(ThreadSafeDictionaryValueFactory<TKey, TValue> valueFactory)
{
Expand All @@ -2146,15 +2147,15 @@ private TValue AddValue(TKey key)
{
if (_dictionary == null)
{
_dictionary = new Dictionary<TKey, TValue>();
_dictionary = new ConcurrentDictionary<TKey, TValue>();
_dictionary[key] = value;
}
else
{
TValue val;
if (_dictionary.TryGetValue(key, out val))
return val;
Dictionary<TKey, TValue> dict = new Dictionary<TKey, TValue>(_dictionary);
var dict = new ConcurrentDictionary<TKey, TValue>(_dictionary);
dict[key] = value;
_dictionary = dict;
}
Expand Down