working on dynamic wrapping, a good awaiting is on way
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
// -----------------------------------------------------------------------
|
||||
using StgSharp.Collections;
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.CompilerServices;
|
||||
@@ -74,46 +75,18 @@ namespace StgSharp.Mathematics.Numeric
|
||||
for (int i = 0; i < count; i++) {
|
||||
_threads.Push(new());
|
||||
}
|
||||
_awaitingLeaderHandle = new ConcurrentQueue<WaitHandle>();
|
||||
IsInitialized = true;
|
||||
}
|
||||
|
||||
public static void LaunchParallel(IEnumerable<MatrixParallelWrap> wraps, SleepMode afterWork)
|
||||
public static void LaunchParallel(MatrixParallelHandle handle, SleepMode afterWork)
|
||||
{
|
||||
RemainThreadCount = _threads.Count;
|
||||
_AfterWork = (ThreadPriority)afterWork;
|
||||
ResetThreadCount();
|
||||
foreach (MatrixParallelWrap w in wraps) {
|
||||
foreach (MatrixParallelWrap w in handle.Wraps) {
|
||||
w.SchedulerReset.Set();
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public static void ResetThreadCount()
|
||||
{
|
||||
RemainThreadCount = _threads.Count;
|
||||
}
|
||||
|
||||
#region wrap field
|
||||
|
||||
public static MatrixParallelThread[] LeadParallel(int recommendCount)
|
||||
{
|
||||
#if NET9_0_OR_GREATER
|
||||
#else
|
||||
Monitor.Enter(_lock);
|
||||
#endif
|
||||
|
||||
return _threads.PopRange(recommendCount);
|
||||
}
|
||||
|
||||
public static void ReleaseParallelLeadership(ref MatrixParallelThread[] pool)
|
||||
{
|
||||
#if NET9_0_OR_GREATER
|
||||
#else
|
||||
Monitor.Exit(_lock);
|
||||
#endif
|
||||
pool = null!;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user