public ThreadWorker (IScheduler sched, ThreadWorker[] others, IProducerConsumerCollection<Task> sharedWorkQueue,
bool createThread, int maxStackSize, ThreadPriority priority)
{
this.others = others;
// if (!string.IsNullOrEmpty (Environment.GetEnvironmentVariable ("USE_CYCLIC"))) {
// Console.WriteLine ("Using cyclic deque");
// this.dDeque = new CyclicDeque<Task> ();
// } else {
// this.dDeque = new DynamicDeque<Task> ();
// }
this.dDeque = new CyclicDeque<Task> ();
this.sharedWorkQueue = sharedWorkQueue;
this.workerLength = others.Length;
this.isLocal = !createThread;
this.childWorkAdder = delegate (Task t) {
dDeque.PushBottom (t);
sched.PulseAll ();
};
// Find the stealing start index randomly (then the traversal
// will be done in Round-Robin fashion)
do {
this.stealingStart = r.Next(0, workerLength);
} while (others[stealingStart] == this);
InitializeUnderlyingThread (maxStackSize, priority);
}