Exemple #1
0
        public ThreadWorker(IScheduler sched, ThreadWorker[] others, IProducerConsumerCollection <Task> sharedWorkQueue,
                            bool createThread, int maxStackSize, ThreadPriority priority)
        {
            this.others = others;

            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);
        }
Exemple #2
0
		public ThreadWorker (IScheduler sched, ThreadWorker[] others, IProducerConsumerCollection<Task> sharedWorkQueue,
		                     bool createThread, int maxStackSize, ThreadPriority priority, EventWaitHandle handle)
		{
			this.others          = others;

			this.dDeque = new CyclicDeque<Task> ();
			
			this.sharedWorkQueue = sharedWorkQueue;
			this.workerLength    = others.Length;
			this.isLocal         = !createThread;
			this.waitHandle      = handle;
			
			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);
		}
Exemple #3
0
		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);
		}
Exemple #4
0
        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);
        }
Exemple #5
0
        public ThreadWorker(ThreadWorker[] others,
                            int workerPosition,
                            IProducerConsumerCollection <Task> sharedWorkQueue,
                            ThreadPriority priority,
                            ManualResetEvent handle)
        {
            this.others          = others;
            this.dDeque          = new CyclicDeque <Task> ();
            this.sharedWorkQueue = sharedWorkQueue;
            this.workerLength    = others.Length;
            this.workerPosition  = workerPosition;
            this.waitHandle      = handle;
            this.threadPriority  = priority;

            InitializeUnderlyingThread();
        }
Exemple #6
0
		public ThreadWorker (IScheduler sched,
		                     ThreadWorker[] others,
		                     int workerPosition,
		                     IProducerConsumerCollection<Task> sharedWorkQueue,
		                     ThreadPriority priority,
		                     ManualResetEvent handle)
		{
			this.others          = others;
			this.dDeque          = new CyclicDeque<Task> ();
			this.sched           = sched;
			this.sharedWorkQueue = sharedWorkQueue;
			this.workerLength    = others.Length;
			this.workerPosition  = workerPosition;
			this.waitHandle      = handle;
			this.threadPriority  = priority;

			InitializeUnderlyingThread ();
		}