private PoolWorker GetPoolWorker(int id) { var poolWorker = new PoolWorker(); poolWorker.Thread = new Thread(() => AssignJob(poolWorker)); poolWorker.Name = $"Worker #{id}"; return(poolWorker); }
private void AssignJob(PoolWorker poolWorker) { poolWorker.IsSpawned = true; SendWorkerToSleep(poolWorker); while (poolWorker.SleepUntilJob(_cancellationToken)) { DoJob(); SignalJobQueueStatus(); poolWorker.SendToSleep(); SendWorkerToSleep(poolWorker); } }
private void SendWorkerToSleep(PoolWorker poolWorker) { _sleepingStack.Push(poolWorker); SignalWorkerAsSleeping(); }