Tiny cleanup

This commit is contained in:
mlemanczyk committed 2023-05-21 02:37:16 +02:00
1 parent fa8f1b029a
commit 26f9666df6
5 files changed
+40 -39

No files matched your search

@@ -14,14 +14,14 @@ namespace Recyclable.Collections.Benchmarks
public partial class RecyclableCollectionsBenchmarks : RecyclableBenchmarkBase<RecyclableCollectionsBenchmarkSource> public partial class RecyclableCollectionsBenchmarks : RecyclableBenchmarkBase<RecyclableCollectionsBenchmarkSource>
{ {
public RecyclableCollectionsBenchmarks() : base() public RecyclableCollectionsBenchmarks() : base()
{ {
TestObjectCount = 1; TestObjectCount = 1;
BaselineBenchmarkType = RecyclableCollectionsBenchmarkSource.PooledList; BaselineBenchmarkType = RecyclableCollectionsBenchmarkSource.PooledList;
BenchmarkType = RecyclableCollectionsBenchmarkSource.RecyclableList; BenchmarkType = RecyclableCollectionsBenchmarkSource.RecyclableList;
} }
[Params [Params
( (
RecyclableCollectionsBenchmarkType.Add_WithCapacity, RecyclableCollectionsBenchmarkType.Add_WithCapacity,
RecyclableCollectionsBenchmarkType.Add, RecyclableCollectionsBenchmarkType.Add,
@@ -91,7 +91,7 @@ namespace Recyclable.Collections.Benchmarks.POC
if (BaselineBenchmarkType != null) if (BaselineBenchmarkType != null)
{ {
Console.WriteLine($"******* SETTING UP BASELINE DATA *******"); Console.WriteLine("******* SETTING UP BASELINE DATA *******");
PrepareData(BaselineBenchmarkType); PrepareData(BaselineBenchmarkType);
_baselineMethod = GetTestMethod(BaselineBenchmarkType); _baselineMethod = GetTestMethod(BaselineBenchmarkType);
} }
@@ -100,7 +100,7 @@ namespace Recyclable.Collections.Benchmarks.POC
//~ One would override another - waste of time & resources. //~ One would override another - waste of time & resources.
if (!EqualityComparer<TBenchmarkType>.Default.Equals(BaselineBenchmarkType, BenchmarkType)) if (!EqualityComparer<TBenchmarkType>.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. //~ If BaselineBenchmarkType == null, then we'll come here only if BaselineBenchmarkType != null.
PrepareData(BenchmarkType!); PrepareData(BenchmarkType!);
_testMethod = GetTestMethod(BenchmarkType); _testMethod = GetTestMethod(BenchmarkType);
@@ -1,6 +1,6 @@
namespace Recyclable.Collections.Parallel namespace Recyclable.Collections.Parallel
{ {
public sealed class ManualResetEventSlimmer public sealed class ManualResetEventSlimmer
{ {
internal bool _isSet; internal bool _isSet;
public bool IsSet => _isSet; public bool IsSet => _isSet;
@@ -1,38 +1,39 @@
namespace Recyclable.Collections.Parallel namespace Recyclable.Collections.Parallel
{ {
public sealed class ParallelSynchronizationContext : IDisposable public sealed class ParallelSynchronizationContext : IDisposable
{ {
public readonly ManualResetEventSlimmer ItemFoundSignal; public readonly ManualResetEventSlimmer ItemFoundSignal;
public readonly Barrier AllDoneSignal;
public long FoundItemIndex;
public Exception? Exception;
internal bool _returned;
public ParallelSynchronizationContext() public readonly Barrier AllDoneSignal;
{ public long FoundItemIndex;
ItemFoundSignal = ManualResetEventSlimmerPool.Create(false); public Exception? Exception;
internal bool _returned;
public ParallelSynchronizationContext()
{
ItemFoundSignal = ManualResetEventSlimmerPool.Create(false);
AllDoneSignal = new(0); AllDoneSignal = new(0);
} }
public ParallelSynchronizationContext(int participantCount) public ParallelSynchronizationContext(int participantCount)
{ {
ItemFoundSignal = ManualResetEventSlimmerPool.Create(false); ItemFoundSignal = ManualResetEventSlimmerPool.Create(false);
AllDoneSignal = new(participantCount); AllDoneSignal = new(participantCount);
} }
public void Dispose() public void Dispose()
{ {
if (!_returned) if (!_returned)
{ {
_returned = true; _returned = true;
ParallelSynchronizationContextPool.Shared.Return(this); ParallelSynchronizationContextPool.Shared.Return(this);
} }
else else
{ {
ItemFoundSignal.Dispose(); ItemFoundSignal.Dispose();
AllDoneSignal.Dispose(); AllDoneSignal.Dispose();
GC.SuppressFinalize(this); GC.SuppressFinalize(this);
} }
} }
} }
} }
+1 -1
View File
@@ -5,7 +5,7 @@ using System.Runtime.CompilerServices;
using Recyclable.Collections.Parallel; using Recyclable.Collections.Parallel;
using Recyclable.Collections.Pools; using Recyclable.Collections.Pools;
[assembly:InternalsVisibleTo("Recyclable.Collections.Benchmarks")] [assembly: InternalsVisibleTo("Recyclable.Collections.Benchmarks")]
namespace Recyclable.Collections namespace Recyclable.Collections
{ {