private RequestThread ( WorkerQueue unclaimedQueue, bool errorRecovery = false ) : PoolWorker | ||
unclaimedQueue | WorkerQueue | |
errorRecovery | bool | |
return | PoolWorker |
internal DedicatedThreadPoolSupervisor(DedicatedThreadPool pool) { //don't set up a timer if a timeout wasn't specified if (pool.Settings.DeadlockTimeout == null) { return; } _timer = new Timer(_ => { //bail in the event of a shutdown if (pool.ShutdownRequested) { return; } for (var i = 0; i < pool.Workers.Length; i++) { var w = pool.Workers[i]; if (Interlocked.Exchange(ref w.Status, 0) == 0) { //this requests a new new worker and calls ForceTermination on the old worker //Potential problem here: if the thread is not dead for real, we might abort real work.. there is no way to tell the difference between //deadlocked or just very long running tasks var newWorker = pool.RequestThread(w, i); continue; } //schedule heartbeat action to worker pool.Workers[i].AddWork(() => Interlocked.Increment(ref w.Status)); } }, null, pool.Settings.DeadlockTimeout.Value, pool.Settings.DeadlockTimeout.Value); }
private void Failover(bool errorRecovery = false) { /* request a new thread then shut down */ _pool.RequestThread(_work, errorRecovery); CurrentWorker = null; _work = null; _workQueue = null; _pool = null; }
internal DedicatedThreadPoolSupervisor(DedicatedThreadPool pool) { //don't set up a timer if a timeout wasn't specified if (pool.Settings.DeadlockTimeout == null) return; _timer = new Timer(_ => { //bail in the event of a shutdown if (pool.ShutdownRequested) return; foreach (var worker in pool.Workers) { var w = worker; if (Interlocked.Exchange(ref w.Status, 0) == 0) { //this requests a new new worker and calls ForceTermination on the old worker //Potential problem here: if the thread is not dead for real, we might abort real work.. there is no way to tell the difference between //deadlocked or just very long running tasks var newWorker = pool.RequestThread(w); continue; } //schedule heartbeat action to worker worker.AddWork(() => { Interlocked.Increment(ref w.Status); }); } }, null, pool.Settings.DeadlockTimeout.Value, pool.Settings.DeadlockTimeout.Value); }