diff options
| author | gdkchan <gab.dark.100@gmail.com> | 2018-03-12 01:04:52 -0300 |
|---|---|---|
| committer | gdkchan <gab.dark.100@gmail.com> | 2018-03-12 01:14:12 -0300 |
| commit | 7a27990faa557c5c93f52e5cb082d551ad119ed0 (patch) | |
| tree | a0800fded014a4a6afe738e5a65a17bc78cf0c19 /Ryujinx.Core/OsHle/Utilities | |
| parent | 3aaa4717b6f7400bac862e589a1f345e70e78d56 (diff) | |
Allow more than one process, free resources on process dispose, implement SvcExitThread
Diffstat (limited to 'Ryujinx.Core/OsHle/Utilities')
| -rw-r--r-- | Ryujinx.Core/OsHle/Utilities/IdPool.cs | 53 | ||||
| -rw-r--r-- | Ryujinx.Core/OsHle/Utilities/IdPoolWithObj.cs | 78 |
2 files changed, 0 insertions, 131 deletions
diff --git a/Ryujinx.Core/OsHle/Utilities/IdPool.cs b/Ryujinx.Core/OsHle/Utilities/IdPool.cs deleted file mode 100644 index a7e181fa..00000000 --- a/Ryujinx.Core/OsHle/Utilities/IdPool.cs +++ /dev/null @@ -1,53 +0,0 @@ -using System.Collections.Generic; - -namespace Ryujinx.Core.OsHle.Utilities -{ - class IdPool - { - private HashSet<int> Ids; - - private int CurrId; - private int MinId; - private int MaxId; - - public IdPool(int Min, int Max) - { - Ids = new HashSet<int>(); - - CurrId = Min; - MinId = Min; - MaxId = Max; - } - - public IdPool() : this(1, int.MaxValue) { } - - public int GenerateId() - { - lock (Ids) - { - for (int Cnt = MinId; Cnt < MaxId; Cnt++) - { - if (Ids.Add(CurrId)) - { - return CurrId; - } - - if (CurrId++ == MaxId) - { - CurrId = MinId; - } - } - - return -1; - } - } - - public bool DeleteId(int Id) - { - lock (Ids) - { - return Ids.Remove(Id); - } - } - } -}
\ No newline at end of file diff --git a/Ryujinx.Core/OsHle/Utilities/IdPoolWithObj.cs b/Ryujinx.Core/OsHle/Utilities/IdPoolWithObj.cs deleted file mode 100644 index f0a339df..00000000 --- a/Ryujinx.Core/OsHle/Utilities/IdPoolWithObj.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Concurrent; -using System.Collections.Generic; - -namespace Ryujinx.Core.OsHle.Utilities -{ - class IdPoolWithObj : IEnumerable<KeyValuePair<int, object>> - { - private IdPool Ids; - - private ConcurrentDictionary<int, object> Objs; - - public IdPoolWithObj() - { - Ids = new IdPool(); - - Objs = new ConcurrentDictionary<int, object>(); - } - - public int GenerateId(object Data) - { - int Id = Ids.GenerateId(); - - if (Id == -1 || !Objs.TryAdd(Id, Data)) - { - throw new InvalidOperationException(); - } - - return Id; - } - - public bool ReplaceData(int Id, object Data) - { - if (Objs.ContainsKey(Id)) - { - Objs[Id] = Data; - - return true; - } - - return false; - } - - public T GetData<T>(int Id) - { - if (Objs.TryGetValue(Id, out object Data) && Data is T) - { - return (T)Data; - } - - return default(T); - } - - public void Delete(int Id) - { - if (Objs.TryRemove(Id, out object Obj)) - { - if (Obj is IDisposable DisposableObj) - { - DisposableObj.Dispose(); - } - - Ids.DeleteId(Id); - } - } - - IEnumerator<KeyValuePair<int, object>> IEnumerable<KeyValuePair<int, object>>.GetEnumerator() - { - return Objs.GetEnumerator(); - } - - IEnumerator IEnumerable.GetEnumerator() - { - return Objs.GetEnumerator(); - } - } -}
\ No newline at end of file |
