forked from Mirror/Ryujinx
Fix race condition on IdDictionary (#333)
This commit is contained in:
parent
827752ec07
commit
0cec4cbee5
1 changed files with 0 additions and 14 deletions
|
@ -8,8 +8,6 @@ namespace Ryujinx.HLE.OsHle
|
||||||
{
|
{
|
||||||
private ConcurrentDictionary<int, object> Objs;
|
private ConcurrentDictionary<int, object> Objs;
|
||||||
|
|
||||||
private int FreeIdHint = 1;
|
|
||||||
|
|
||||||
public IdDictionary()
|
public IdDictionary()
|
||||||
{
|
{
|
||||||
Objs = new ConcurrentDictionary<int, object>();
|
Objs = new ConcurrentDictionary<int, object>();
|
||||||
|
@ -21,16 +19,6 @@ namespace Ryujinx.HLE.OsHle
|
||||||
}
|
}
|
||||||
|
|
||||||
public int Add(object Data)
|
public int Add(object Data)
|
||||||
{
|
|
||||||
if (Objs.TryAdd(FreeIdHint, Data))
|
|
||||||
{
|
|
||||||
return FreeIdHint++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return AddSlow(Data);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int AddSlow(object Data)
|
|
||||||
{
|
{
|
||||||
for (int Id = 1; Id < int.MaxValue; Id++)
|
for (int Id = 1; Id < int.MaxValue; Id++)
|
||||||
{
|
{
|
||||||
|
@ -67,8 +55,6 @@ namespace Ryujinx.HLE.OsHle
|
||||||
{
|
{
|
||||||
if (Objs.TryRemove(Id, out object Obj))
|
if (Objs.TryRemove(Id, out object Obj))
|
||||||
{
|
{
|
||||||
FreeIdHint = Id;
|
|
||||||
|
|
||||||
return Obj;
|
return Obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue