diff --git a/Misaki.HighPerformance.Jobs/Misaki.HighPerformance.Jobs.csproj b/Misaki.HighPerformance.Jobs/Misaki.HighPerformance.Jobs.csproj
index dbdb291..1cf15c0 100644
--- a/Misaki.HighPerformance.Jobs/Misaki.HighPerformance.Jobs.csproj
+++ b/Misaki.HighPerformance.Jobs/Misaki.HighPerformance.Jobs.csproj
@@ -1,17 +1,18 @@
- Library
net10.0
enable
enable
True
true
- 1.3.0
+ 1.3.1
$(AssemblyVersion)
Misaki
https://git.personalnas.com/Misaki/Misaki.HighPerformance.git
https://git.personalnas.com/Misaki/Misaki.HighPerformance.git
+ false
+ contentFiles
@@ -27,4 +28,13 @@
+
+
+ true
+ contentFiles\cs\any\Misaki.HighPerformance.Jobs\
+ false
+ Compile
+
+
+
diff --git a/Misaki.HighPerformance.Jobs/AssemblyInfo.cs.cs b/Misaki.HighPerformance.Jobs/contentFiles/cs/any/AssemblyInfo.cs.cs
similarity index 100%
rename from Misaki.HighPerformance.Jobs/AssemblyInfo.cs.cs
rename to Misaki.HighPerformance.Jobs/contentFiles/cs/any/AssemblyInfo.cs.cs
diff --git a/Misaki.HighPerformance.Jobs/IJob.cs b/Misaki.HighPerformance.Jobs/contentFiles/cs/any/IJob.cs
similarity index 100%
rename from Misaki.HighPerformance.Jobs/IJob.cs
rename to Misaki.HighPerformance.Jobs/contentFiles/cs/any/IJob.cs
diff --git a/Misaki.HighPerformance.Jobs/JobExecutor.cs b/Misaki.HighPerformance.Jobs/contentFiles/cs/any/JobExecutor.cs
similarity index 100%
rename from Misaki.HighPerformance.Jobs/JobExecutor.cs
rename to Misaki.HighPerformance.Jobs/contentFiles/cs/any/JobExecutor.cs
diff --git a/Misaki.HighPerformance.Jobs/JobHandle.cs b/Misaki.HighPerformance.Jobs/contentFiles/cs/any/JobHandle.cs
similarity index 100%
rename from Misaki.HighPerformance.Jobs/JobHandle.cs
rename to Misaki.HighPerformance.Jobs/contentFiles/cs/any/JobHandle.cs
diff --git a/Misaki.HighPerformance.Jobs/JobInfo.cs b/Misaki.HighPerformance.Jobs/contentFiles/cs/any/JobInfo.cs
similarity index 100%
rename from Misaki.HighPerformance.Jobs/JobInfo.cs
rename to Misaki.HighPerformance.Jobs/contentFiles/cs/any/JobInfo.cs
diff --git a/Misaki.HighPerformance.Jobs/JobScheduler.cs b/Misaki.HighPerformance.Jobs/contentFiles/cs/any/JobScheduler.cs
similarity index 99%
rename from Misaki.HighPerformance.Jobs/JobScheduler.cs
rename to Misaki.HighPerformance.Jobs/contentFiles/cs/any/JobScheduler.cs
index c85592c..f38e416 100644
--- a/Misaki.HighPerformance.Jobs/JobScheduler.cs
+++ b/Misaki.HighPerformance.Jobs/contentFiles/cs/any/JobScheduler.cs
@@ -266,6 +266,8 @@ public sealed unsafe partial class JobScheduler : IJobScheduler, IDisposable
private bool _disposed = false;
+ internal volatile int _totalJobCount;
+
internal bool IsCancellationRequested => _cts.IsCancellationRequested;
public int WorkerCount => _workerThreads.Length;
@@ -333,6 +335,7 @@ public sealed unsafe partial class JobScheduler : IJobScheduler, IDisposable
jobQueue.Enqueue(handle);
}
+ Interlocked.Increment(ref _totalJobCount);
_workSignal.Release(handleCount);
}
}
@@ -501,7 +504,7 @@ public sealed unsafe partial class JobScheduler : IJobScheduler, IDisposable
if (state == JobState.Completed)
{
- return; // Already completed (shouldn't happen for single-execution jobs)
+ return;
}
//if (state != JobState.Running)
@@ -535,11 +538,7 @@ public sealed unsafe partial class JobScheduler : IJobScheduler, IDisposable
}
// We now have exclusive access to dependentsID (no new readers, old readers finished).
- // Safely capture dependents.
var dependentCount = info.dependentCount;
- dependentCount = Math.Min(dependentCount, JobInfo.MAX_DEPENDENTS); // Safety cap
-
- // Use stackalloc to avoid allocation, but we'll copy to notify after freeing parent.
var dependentsToNotify = stackalloc JobHandle[dependentCount];
for (var i = 0; i < dependentCount; i++)
{
@@ -548,6 +547,7 @@ public sealed unsafe partial class JobScheduler : IJobScheduler, IDisposable
_jobDataAllocator.Free(info.pJobData);
_jobInfoPool.Remove(handle.ID, handle.Generation);
+ Interlocked.Decrement(ref _totalJobCount);
for (var i = 0; i < dependentCount; i++)
{
diff --git a/Misaki.HighPerformance.Jobs/TempJobAllocator.cs b/Misaki.HighPerformance.Jobs/contentFiles/cs/any/TempJobAllocator.cs
similarity index 100%
rename from Misaki.HighPerformance.Jobs/TempJobAllocator.cs
rename to Misaki.HighPerformance.Jobs/contentFiles/cs/any/TempJobAllocator.cs
diff --git a/Misaki.HighPerformance.Jobs/WorkerThread.cs b/Misaki.HighPerformance.Jobs/contentFiles/cs/any/WorkerThread.cs
similarity index 85%
rename from Misaki.HighPerformance.Jobs/WorkerThread.cs
rename to Misaki.HighPerformance.Jobs/contentFiles/cs/any/WorkerThread.cs
index 33e0d2c..d946168 100644
--- a/Misaki.HighPerformance.Jobs/WorkerThread.cs
+++ b/Misaki.HighPerformance.Jobs/contentFiles/cs/any/WorkerThread.cs
@@ -33,6 +33,12 @@ internal class WorkerThread : IDisposable
private bool TryFindJob(out JobHandle handle)
{
+ if (Interlocked.CompareExchange(ref _scheduler._totalJobCount, 0, 0) == 0)
+ {
+ handle = JobHandle.Invalid;
+ return false;
+ }
+
if (_localQueue.TryDequeue(out handle))
{
return true;
@@ -95,13 +101,10 @@ internal class WorkerThread : IDisposable
}
ref var jobInfo = ref _scheduler.GetJobInfoReference(handle, out var exist);
- if (exist)
+ if (exist && Interlocked.CompareExchange(ref jobInfo.state, JobState.Running, JobState.Scheduled) == JobState.Scheduled)
{
- Interlocked.CompareExchange(ref jobInfo.state, JobState.Running, JobState.Scheduled);
- var executeDelegate = jobInfo.pExecutionFunc;
-
- if (executeDelegate == null
- || executeDelegate(jobInfo.pJobData, ref jobInfo.jobRanges, ref jobInfo.remainingBatches, _index))
+ if (jobInfo.pExecutionFunc == null
+ || jobInfo.pExecutionFunc(jobInfo.pJobData, ref jobInfo.jobRanges, ref jobInfo.remainingBatches, _index))
{
_scheduler.MarkJobComplete(handle);
}
diff --git a/Misaki.HighPerformance.LowLevel/Misaki.HighPerformance.LowLevel.csproj b/Misaki.HighPerformance.LowLevel/Misaki.HighPerformance.LowLevel.csproj
index fb31b18..611e7c2 100644
--- a/Misaki.HighPerformance.LowLevel/Misaki.HighPerformance.LowLevel.csproj
+++ b/Misaki.HighPerformance.LowLevel/Misaki.HighPerformance.LowLevel.csproj
@@ -7,12 +7,10 @@
true
true
Misaki
- 1.3.7
+ 1.3.8
$(AssemblyVersion)
https://git.personalnas.com/Misaki/Misaki.HighPerformance.git
https://git.personalnas.com/Misaki/Misaki.HighPerformance.git
- true
- snupkg
false
contentFiles
@@ -33,7 +31,8 @@
true
- contentFiles\cs\any\
+ contentFiles\cs\any\Misaki.HighPerformance.LowLevel\
+ false
Compile