swiss ok, needs more benchmark
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
//-----------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------
|
||||
// -----------------------------------------------------------------------
|
||||
// file="MatrixParallel.Await"
|
||||
// Project: StgSharp
|
||||
@@ -31,6 +31,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace StgSharp.Mathematics.Numeric
|
||||
@@ -43,7 +44,9 @@ namespace StgSharp.Mathematics.Numeric
|
||||
private static volatile int _createGeneration = 0;
|
||||
private static int _sortState;
|
||||
|
||||
public static MatrixParallelThread[] LeadParallel(int recommendCount)
|
||||
public static MatrixParallelThread[] LeadParallel(
|
||||
int recommendCount
|
||||
)
|
||||
{
|
||||
int min = int.Min(recommendCount, _threads.Capacity);
|
||||
min /= 2;
|
||||
@@ -108,7 +111,9 @@ namespace StgSharp.Mathematics.Numeric
|
||||
// return ret;
|
||||
}
|
||||
|
||||
public static void ReturnParallelResources(ref MatrixParallelThread[] pool)
|
||||
public static void ReturnParallelResources(
|
||||
ref MatrixParallelThread[] pool
|
||||
)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
@@ -123,7 +128,11 @@ namespace StgSharp.Mathematics.Numeric
|
||||
pool = null!;
|
||||
}
|
||||
|
||||
private record class WaitHandle(int generation, int least, int best)
|
||||
private record class WaitHandle(
|
||||
int generation,
|
||||
int least,
|
||||
int best
|
||||
)
|
||||
{
|
||||
|
||||
public int CreateGeneration { get; init; } = generation;
|
||||
@@ -135,7 +144,9 @@ namespace StgSharp.Mathematics.Numeric
|
||||
public int Priority { get; private set; }
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void UpdatePriority(int currentGeneration)
|
||||
public void UpdatePriority(
|
||||
int currentGeneration
|
||||
)
|
||||
{
|
||||
Priority = (currentGeneration - CreateGeneration) * (MatrixParallel._threads.Capacity - LeastCount);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user