fix(workerthread): improve job state transition logic

Updated job state transition in WorkerThread to allow jobs already in the Running state to proceed, preventing unnecessary skipping. Also incremented project version to 1.5.8.

This change ensures jobs are not skipped if their state is already Running, improving reliability in job execution.
This commit is contained in:
2026-04-01 02:33:12 +09:00
parent 38209d1a6f
commit 299426b48b
2 changed files with 8 additions and 2 deletions

View File

@@ -6,7 +6,7 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks> <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild> <GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<AssemblyVersion>1.5.7</AssemblyVersion> <AssemblyVersion>1.5.8</AssemblyVersion>
<Version>$(AssemblyVersion)</Version> <Version>$(AssemblyVersion)</Version>
<Authors>Misaki</Authors> <Authors>Misaki</Authors>
<PackageProjectUrl>https://git.personalnas.com/Misaki/Misaki.HighPerformance.git</PackageProjectUrl> <PackageProjectUrl>https://git.personalnas.com/Misaki/Misaki.HighPerformance.git</PackageProjectUrl>

View File

@@ -101,8 +101,14 @@ internal class WorkerThread : IDisposable
} }
ref var jobInfo = ref _scheduler.GetJobInfoReference(handle, out var exist); ref var jobInfo = ref _scheduler.GetJobInfoReference(handle, out var exist);
if (exist && Interlocked.CompareExchange(ref jobInfo.state, JobState.Running, JobState.Scheduled) == JobState.Scheduled) if (exist)
{ {
var priorState = Interlocked.CompareExchange(ref jobInfo.state, JobState.Running, JobState.Scheduled);
if (priorState != JobState.Scheduled && priorState != JobState.Running)
{
continue;
}
if (jobInfo.pExecutionFunc != null) if (jobInfo.pExecutionFunc != null)
{ {
var ctx = new JobExecutionContext(_index, _scheduler); var ctx = new JobExecutionContext(_index, _scheduler);