From 299426b48b11c129f5a69e9f6dca10b0b283a6c5 Mon Sep 17 00:00:00 2001 From: Misaki Date: Wed, 1 Apr 2026 02:33:12 +0900 Subject: [PATCH] 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. --- .../Misaki.HighPerformance.Jobs.csproj | 2 +- Misaki.HighPerformance.Jobs/WorkerThread.cs | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Misaki.HighPerformance.Jobs/Misaki.HighPerformance.Jobs.csproj b/Misaki.HighPerformance.Jobs/Misaki.HighPerformance.Jobs.csproj index 3e3e220..f1db093 100644 --- a/Misaki.HighPerformance.Jobs/Misaki.HighPerformance.Jobs.csproj +++ b/Misaki.HighPerformance.Jobs/Misaki.HighPerformance.Jobs.csproj @@ -6,7 +6,7 @@ enable True True - 1.5.7 + 1.5.8 $(AssemblyVersion) Misaki https://git.personalnas.com/Misaki/Misaki.HighPerformance.git diff --git a/Misaki.HighPerformance.Jobs/WorkerThread.cs b/Misaki.HighPerformance.Jobs/WorkerThread.cs index 93e3b60..36bda34 100644 --- a/Misaki.HighPerformance.Jobs/WorkerThread.cs +++ b/Misaki.HighPerformance.Jobs/WorkerThread.cs @@ -101,8 +101,14 @@ internal class WorkerThread : IDisposable } 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) { var ctx = new JobExecutionContext(_index, _scheduler);