diff --git a/Example.Backend/LoadTestImp.cs b/Example.Backend/LoadTestImp.cs index a3752e5..443d61a 100644 --- a/Example.Backend/LoadTestImp.cs +++ b/Example.Backend/LoadTestImp.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using System.Threading; using System.Threading.Tasks; using Example.Shared; @@ -21,7 +22,7 @@ namespace Example.Backend public void C() { - throw new NotImplementedException(); + Environment.Exit(0); } public void A() diff --git a/Example.Frontend/Program.cs b/Example.Frontend/Program.cs index 6e91b88..08c8b45 100644 --- a/Example.Frontend/Program.cs +++ b/Example.Frontend/Program.cs @@ -131,7 +131,7 @@ class Program DemoCheck.TaskCancelation = true; #endif - const int iterations = 10000; + const int iterations = 10_000; var timer = Stopwatch.StartNew(); var x = 0; for (int i = 0; i < iterations; i++) diff --git a/Example.Shared/ILoadTest.cs b/Example.Shared/ILoadTest.cs index 4d9bc21..54212b3 100644 --- a/Example.Shared/ILoadTest.cs +++ b/Example.Shared/ILoadTest.cs @@ -13,7 +13,6 @@ namespace Example.Shared int Last(int next); void C(); void A(); - Task AsyncTest(CancellationToken token = default); } } \ No newline at end of file diff --git a/mROA.Cbor/CborSerializationToolkit.cs b/mROA.Cbor/CborSerializationToolkit.cs index 7943956..a17cd39 100644 --- a/mROA.Cbor/CborSerializationToolkit.cs +++ b/mROA.Cbor/CborSerializationToolkit.cs @@ -13,7 +13,7 @@ namespace mROA.Cbor { public class CborSerializationToolkit : IContextualSerializationToolKit { - private static Dictionary> _propertiesCache = new(); + private Dictionary> _propertiesCache = new(); public static TimeSpan SerializationTime = TimeSpan.Zero; public byte[] Serialize(object objectToSerialize, IEndPointContext context) { @@ -232,7 +232,7 @@ namespace mROA.Cbor return; } - var properties = GetAvalibleProperties(type); + var properties = GetAvailableProperties(type); var values = properties.Select(property => property.GetValue(obj)).ToList(); WriteList(values, writer, context); } @@ -403,7 +403,7 @@ namespace mROA.Cbor private void FillObject(object obj, Type type, CborReader reader, IEndPointContext? context) { - var properties = GetAvalibleProperties(type); + var properties = GetAvailableProperties(type); var length = reader.ReadStartArray(); try { @@ -441,7 +441,7 @@ namespace mROA.Cbor return finalProperties; } - private List GetAvalibleProperties(Type type) + private List GetAvailableProperties(Type type) { if (_propertiesCache.TryGetValue(type, out var properties)) { diff --git a/mROA.sln b/mROA.sln index 4532adc..da86d99 100644 --- a/mROA.sln +++ b/mROA.sln @@ -25,6 +25,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "TotalDemo", "TotalDemo", "{ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "mROA.CodegenTools", "mROA.CodegenTools\mROA.CodegenTools.csproj", "{FFB8DFAE-17F0-4335-8F17-187B3619E8F2}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Example.Load", "Example.Load\Example.Load.csproj", "{930B236B-BDAA-4B8C-8054-5B992BAE6622}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -67,6 +69,10 @@ Global {FFB8DFAE-17F0-4335-8F17-187B3619E8F2}.Debug|Any CPU.Build.0 = Debug|Any CPU {FFB8DFAE-17F0-4335-8F17-187B3619E8F2}.Release|Any CPU.ActiveCfg = Release|Any CPU {FFB8DFAE-17F0-4335-8F17-187B3619E8F2}.Release|Any CPU.Build.0 = Release|Any CPU + {930B236B-BDAA-4B8C-8054-5B992BAE6622}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {930B236B-BDAA-4B8C-8054-5B992BAE6622}.Debug|Any CPU.Build.0 = Debug|Any CPU + {930B236B-BDAA-4B8C-8054-5B992BAE6622}.Release|Any CPU.ActiveCfg = Release|Any CPU + {930B236B-BDAA-4B8C-8054-5B992BAE6622}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -76,5 +82,6 @@ Global {A9BB364E-0BA6-40B9-A293-757BC48EFC06} = {FC4FA752-10A7-4D78-A7C2-9BCD8A81FB5E} {9BD25A13-3165-47C0-9EAA-5C59EC490E32} = {FC4FA752-10A7-4D78-A7C2-9BCD8A81FB5E} {E7703F5B-F2A6-4A88-AA57-EBB1E38D533E} = {FC4FA752-10A7-4D78-A7C2-9BCD8A81FB5E} + {930B236B-BDAA-4B8C-8054-5B992BAE6622} = {FC4FA752-10A7-4D78-A7C2-9BCD8A81FB5E} EndGlobalSection EndGlobal diff --git a/mROA/Implementation/CancellationRepository.cs b/mROA/Implementation/CancellationRepository.cs index d6543aa..3bc93c2 100644 --- a/mROA/Implementation/CancellationRepository.cs +++ b/mROA/Implementation/CancellationRepository.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Threading; using mROA.Abstract; @@ -7,7 +8,7 @@ namespace mROA.Implementation { public class CancellationRepository : ICancellationRepository { - private Dictionary _cancellations = new(); + private ConcurrentDictionary _cancellations = new(); public void RegisterCancellation(Guid id, CancellationTokenSource cts) { @@ -16,12 +17,12 @@ namespace mROA.Implementation public CancellationTokenSource? GetCancellation(Guid id) { - return _cancellations.GetValueOrDefault(id, null); + return _cancellations.GetValueOrDefault(id); } public void FreeCancelation(Guid id) { - _cancellations.Remove(id); + _cancellations.Remove(id, out _); } public void Inject(T dependency)