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:
@@ -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>
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user