Skip to content

Commit

Permalink
更新ILRuntime至2020/9/18 19:45:42
Browse files Browse the repository at this point in the history
  • Loading branch information
wuxiongbin committed Sep 21, 2020
1 parent 3c3716a commit d6c7961
Show file tree
Hide file tree
Showing 7 changed files with 1,467 additions and 1,163 deletions.
262 changes: 130 additions & 132 deletions Assets/XIL/ILSource/ILRuntime/Other/ThreadSafeDictionary.cs
Original file line number Diff line number Diff line change
@@ -1,132 +1,130 @@
#if USE_HOTusing System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Runtime.Versioning;
using System.Threading;

namespace ILRuntime.Other
{
/// <summary>
/// A thread safe dictionary for internal use
/// </summary>
/// <typeparam name="K"></typeparam>
/// <typeparam name="V"></typeparam>
class ThreadSafeDictionary<K, V> : IDictionary<K, V>
{
Dictionary<K, V> dic = new Dictionary<K, V>();

public Dictionary<K,V> InnerDictionary { get { return dic; } }
public V this[K key]
{
get
{
lock(dic)
return dic[key];
}

set
{
lock(dic)
dic[key] = value;
}
}

public int Count
{
get
{
lock(dic)
return dic.Count;
}
}

public bool IsReadOnly
{
get
{
lock(dic)
return IsReadOnly;
}
}

public ICollection<K> Keys
{
get
{
throw new NotImplementedException();
}
}

public ICollection<V> Values
{
get
{
throw new NotImplementedException();
}
}

public void Add(KeyValuePair<K, V> item)
{
lock (dic)
dic.Add(item.Key, item.Value);
}

public void Add(K key, V value)
{
lock(dic)
dic.Add(key, value);
}

public void Clear()
{
lock(dic)
dic.Clear();
}

public bool Contains(KeyValuePair<K, V> item)
{
lock(dic)
return dic.ContainsKey(item.Key);
}

public bool ContainsKey(K key)
{
lock(dic)
return dic.ContainsKey(key);
}

public void CopyTo(KeyValuePair<K, V>[] array, int arrayIndex)
{
throw new NotImplementedException();
}

public IEnumerator<KeyValuePair<K, V>> GetEnumerator()
{
throw new NotImplementedException();
}

public bool Remove(KeyValuePair<K, V> item)
{
throw new NotImplementedException();
}

public bool Remove(K key)
{
lock(dic)
return dic.Remove(key);
}

public bool TryGetValue(K key, out V value)
{
lock(dic)
return dic.TryGetValue(key, out value);
}

IEnumerator IEnumerable.GetEnumerator()
{
throw new NotImplementedException();
}
}
}#endif
#if USE_HOT
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Runtime.Versioning;
using System.Threading;

namespace ILRuntime.Other
{
/// <summary>
/// A thread safe dictionary for internal use
/// </summary>
/// <typeparam name="K"></typeparam>
/// <typeparam name="V"></typeparam>
class ThreadSafeDictionary<K, V> : IDictionary<K, V>
{
Dictionary<K, V> dic = new Dictionary<K, V>();

public Dictionary<K,V> InnerDictionary { get { return dic; } }
public V this[K key]
{
get
{
return dic[key];
}

set
{
lock(dic)
dic[key] = value;
}
}

public int Count
{
get
{
lock(dic)
return dic.Count;
}
}

public bool IsReadOnly
{
get
{
lock(dic)
return IsReadOnly;
}
}

public ICollection<K> Keys
{
get
{
throw new NotImplementedException();
}
}

public ICollection<V> Values
{
get
{
throw new NotImplementedException();
}
}

public void Add(KeyValuePair<K, V> item)
{
lock (dic)
dic.Add(item.Key, item.Value);
}

public void Add(K key, V value)
{
lock(dic)
dic.Add(key, value);
}

public void Clear()
{
lock(dic)
dic.Clear();
}

public bool Contains(KeyValuePair<K, V> item)
{
return dic.ContainsKey(item.Key);
}

public bool ContainsKey(K key)
{
return dic.ContainsKey(key);
}

public void CopyTo(KeyValuePair<K, V>[] array, int arrayIndex)
{
throw new NotImplementedException();
}

public IEnumerator<KeyValuePair<K, V>> GetEnumerator()
{
throw new NotImplementedException();
}

public bool Remove(KeyValuePair<K, V> item)
{
throw new NotImplementedException();
}

public bool Remove(K key)
{
lock(dic)
return dic.Remove(key);
}

public bool TryGetValue(K key, out V value)
{
return dic.TryGetValue(key, out value);
}

IEnumerator IEnumerable.GetEnumerator()
{
throw new NotImplementedException();
}
}
}
#endif
Loading

0 comments on commit d6c7961

Please sign in to comment.