swiss ok, needs more benchmark

This commit is contained in:
Youmu Liu
2026-03-06 18:22:30 +08:00
parent 83997f64d0
commit f6e897ed06
70 changed files with 1889 additions and 3371 deletions
@@ -1,4 +1,4 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// file="MatrixParallel.AwaitingQueue"
// Project: StgSharp
@@ -51,19 +51,24 @@ namespace StgSharp.Mathematics.Numeric
public AwaitingQueue() { }
public void Enqueue(WaitHandle handle)
public void Enqueue(
WaitHandle handle
)
{
if (_count > 7)
{
_fallback.Enqueue(handle);
Interlocked.Increment(ref _count);
_ = Interlocked.Increment(ref _count);
return;
}
_quickElements[_count] = handle;
Interlocked.Increment(ref _count);
_ = Interlocked.Increment(ref _count);
}
public bool TryDequeue(int generation, out WaitHandle handle)
public bool TryDequeue(
int generation,
out WaitHandle handle
)
{
if (_count == 0)
{
@@ -83,7 +88,10 @@ namespace StgSharp.Mathematics.Numeric
return true;
}
public bool TryPeek(int generation, out WaitHandle handle)
public bool TryPeek(
int generation,
out WaitHandle handle
)
{
if (_count == 0)
{
@@ -99,7 +107,10 @@ namespace StgSharp.Mathematics.Numeric
return true;
}
public bool TryPopIfRefEqual(int generation, in WaitHandle handle)
public bool TryPopIfRefEqual(
int generation,
in WaitHandle handle
)
{
if (_count == 0) {
return false;
@@ -127,7 +138,9 @@ namespace StgSharp.Mathematics.Numeric
private WaitHandle value;
public static void Sort(ref Element e)
public static void Sort(
ref Element e
)
{
int maxIdx = 0;
WaitHandle first = e[0];