add safty check for preferLocal

This commit is contained in:
2026-05-02 21:31:32 +09:00
parent a048305ebf
commit b801e70f62
2 changed files with 38 additions and 46 deletions

View File

@@ -6,6 +6,8 @@ internal class WorkerThread : IDisposable
{
[ThreadStatic]
private static int t_threadIndex;
[ThreadStatic]
private static bool t_isWorkerThread;
private readonly SPMCQueue<JobHandle>[] _localQueue;
private readonly Thread _thread;
@@ -17,6 +19,7 @@ internal class WorkerThread : IDisposable
private uint _priorityTick;
public static int ThreadIndex => t_threadIndex;
public static bool IsWorkerThread => t_isWorkerThread;
public ReadOnlySpan<SPMCQueue<JobHandle>> LocalQueues => _localQueue;
@@ -100,6 +103,7 @@ internal class WorkerThread : IDisposable
Debug.Assert(index != null);
t_threadIndex = (int)index;
t_isWorkerThread = true;
while (!_scheduler.IsCancellationRequested)
{