Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
ZjzMisaka committed Nov 11, 2023
1 parent 3dd7508 commit 0bff54c
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions PowerThreadPool/PowerThreadPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -767,20 +767,20 @@ internal void SetWork(WorkBase work)
/// <returns></returns>
private Worker GetWorker()
{

Worker worker = null;
while (idleWorkerQueue.TryDequeue(out string firstWorkerID))

Worker worker = null;
while (idleWorkerQueue.TryDequeue(out string firstWorkerID))
{
if (idleWorkerDic.TryRemove(firstWorkerID, out worker))
{
if (idleWorkerDic.TryRemove(firstWorkerID, out worker))
if (Interlocked.Increment(ref worker.gettedLock) == -99)
{
if (Interlocked.Increment(ref worker.gettedLock) == -99)
{
Interlocked.Exchange(ref worker.gettedLock, -100);
continue;
}
return worker;
Interlocked.Exchange(ref worker.gettedLock, -100);
continue;
}
return worker;
}
}

lock (this)
{
Expand Down Expand Up @@ -817,9 +817,9 @@ private Worker GetWorker()
}
}
}

return worker;
}

return worker;
}

/// <summary>
Expand Down

0 comments on commit 0bff54c

Please sign in to comment.