From 26f9666df63b79068ecadec92512c3fe06dee250 Mon Sep 17 00:00:00 2001 From: mlemanczyk Date: Sun, 21 May 2023 02:25:18 +0200 Subject: [PATCH] Tiny cleanup --- .../RecyclableCollections.Benchmarks.cs | 8 +-- .../POC/PocBenchmarkBase.cs | 4 +- .../Parallel/ManualResetEventSlimmer.cs | 2 +- .../ParallelSynchronizationContext.cs | 63 ++++++++++--------- Recyclable.Collections/RecyclableList.cs | 2 +- 5 files changed, 40 insertions(+), 39 deletions(-) diff --git a/Recyclable.Collections.Benchmarks/Benchmarks/RecyclableCollections.Benchmarks.cs b/Recyclable.Collections.Benchmarks/Benchmarks/RecyclableCollections.Benchmarks.cs index bae12f8..1c6d12a 100644 --- a/Recyclable.Collections.Benchmarks/Benchmarks/RecyclableCollections.Benchmarks.cs +++ b/Recyclable.Collections.Benchmarks/Benchmarks/RecyclableCollections.Benchmarks.cs @@ -14,14 +14,14 @@ namespace Recyclable.Collections.Benchmarks public partial class RecyclableCollectionsBenchmarks : RecyclableBenchmarkBase { - public RecyclableCollectionsBenchmarks() : base() - { + public RecyclableCollectionsBenchmarks() : base() + { TestObjectCount = 1; BaselineBenchmarkType = RecyclableCollectionsBenchmarkSource.PooledList; BenchmarkType = RecyclableCollectionsBenchmarkSource.RecyclableList; - } + } - [Params + [Params ( RecyclableCollectionsBenchmarkType.Add_WithCapacity, RecyclableCollectionsBenchmarkType.Add, diff --git a/Recyclable.Collections.Benchmarks/POC/PocBenchmarkBase.cs b/Recyclable.Collections.Benchmarks/POC/PocBenchmarkBase.cs index 2446dab..12af85a 100644 --- a/Recyclable.Collections.Benchmarks/POC/PocBenchmarkBase.cs +++ b/Recyclable.Collections.Benchmarks/POC/PocBenchmarkBase.cs @@ -91,7 +91,7 @@ namespace Recyclable.Collections.Benchmarks.POC if (BaselineBenchmarkType != null) { - Console.WriteLine($"******* SETTING UP BASELINE DATA *******"); + Console.WriteLine("******* SETTING UP BASELINE DATA *******"); PrepareData(BaselineBenchmarkType); _baselineMethod = GetTestMethod(BaselineBenchmarkType); } @@ -100,7 +100,7 @@ namespace Recyclable.Collections.Benchmarks.POC //~ One would override another - waste of time & resources. if (!EqualityComparer.Default.Equals(BaselineBenchmarkType, BenchmarkType)) { - Console.WriteLine($"******* SETTING UP TEST CASE DATA *******"); + Console.WriteLine("******* SETTING UP TEST CASE DATA *******"); //~ If BaselineBenchmarkType == null, then we'll come here only if BaselineBenchmarkType != null. PrepareData(BenchmarkType!); _testMethod = GetTestMethod(BenchmarkType); diff --git a/Recyclable.Collections/Parallel/ManualResetEventSlimmer.cs b/Recyclable.Collections/Parallel/ManualResetEventSlimmer.cs index c56260c..042e49a 100644 --- a/Recyclable.Collections/Parallel/ManualResetEventSlimmer.cs +++ b/Recyclable.Collections/Parallel/ManualResetEventSlimmer.cs @@ -1,6 +1,6 @@ namespace Recyclable.Collections.Parallel { - public sealed class ManualResetEventSlimmer + public sealed class ManualResetEventSlimmer { internal bool _isSet; public bool IsSet => _isSet; diff --git a/Recyclable.Collections/Parallel/ParallelSynchronizationContext.cs b/Recyclable.Collections/Parallel/ParallelSynchronizationContext.cs index 649027c..e41c3f0 100644 --- a/Recyclable.Collections/Parallel/ParallelSynchronizationContext.cs +++ b/Recyclable.Collections/Parallel/ParallelSynchronizationContext.cs @@ -1,38 +1,39 @@ namespace Recyclable.Collections.Parallel { - public sealed class ParallelSynchronizationContext : IDisposable - { - public readonly ManualResetEventSlimmer ItemFoundSignal; - public readonly Barrier AllDoneSignal; - public long FoundItemIndex; - public Exception? Exception; - internal bool _returned; + public sealed class ParallelSynchronizationContext : IDisposable + { + public readonly ManualResetEventSlimmer ItemFoundSignal; - public ParallelSynchronizationContext() - { - ItemFoundSignal = ManualResetEventSlimmerPool.Create(false); + public readonly Barrier AllDoneSignal; + public long FoundItemIndex; + public Exception? Exception; + internal bool _returned; + + public ParallelSynchronizationContext() + { + ItemFoundSignal = ManualResetEventSlimmerPool.Create(false); AllDoneSignal = new(0); - } + } - public ParallelSynchronizationContext(int participantCount) - { - ItemFoundSignal = ManualResetEventSlimmerPool.Create(false); - AllDoneSignal = new(participantCount); - } + public ParallelSynchronizationContext(int participantCount) + { + ItemFoundSignal = ManualResetEventSlimmerPool.Create(false); + AllDoneSignal = new(participantCount); + } - public void Dispose() - { - if (!_returned) - { - _returned = true; - ParallelSynchronizationContextPool.Shared.Return(this); - } - else - { - ItemFoundSignal.Dispose(); - AllDoneSignal.Dispose(); - GC.SuppressFinalize(this); - } - } - } + public void Dispose() + { + if (!_returned) + { + _returned = true; + ParallelSynchronizationContextPool.Shared.Return(this); + } + else + { + ItemFoundSignal.Dispose(); + AllDoneSignal.Dispose(); + GC.SuppressFinalize(this); + } + } + } } \ No newline at end of file diff --git a/Recyclable.Collections/RecyclableList.cs b/Recyclable.Collections/RecyclableList.cs index 7e64195..f3c1a24 100644 --- a/Recyclable.Collections/RecyclableList.cs +++ b/Recyclable.Collections/RecyclableList.cs @@ -5,7 +5,7 @@ using System.Runtime.CompilerServices; using Recyclable.Collections.Parallel; using Recyclable.Collections.Pools; -[assembly:InternalsVisibleTo("Recyclable.Collections.Benchmarks")] +[assembly: InternalsVisibleTo("Recyclable.Collections.Benchmarks")] namespace Recyclable.Collections {