Esempio n. 1
0
        public static void For(SBThreadPool pool, int inclusiveStart, int exclusiveEnd, ParallelForIterationDelegate iterate)
        {
            if(inclusiveStart >= exclusiveEnd)
                return;

            using (ParallelForRun loopRun = new ParallelForRun(exclusiveEnd - inclusiveStart, inclusiveStart, iterate))
            {
                for (int i = 0; i < pool.NumThreads; i++)
                {
                    SBJob job = new ParallelForJob(loopRun);
                    job.QueueInPool(pool);
                }
                loopRun.ThreadRunIterations();
                loopRun.Join();
            }
        }
Esempio n. 2
0
 public abstract void Run(SBThreadPool pool);
Esempio n. 3
0
#pragma warning restore 0420

        public void QueueInPool(SBThreadPool pool)
        {
            finishedVar = 0;
            pool.AddWork(RunAndMarkDone);
        }
Esempio n. 4
0
#pragma warning disable 0420    // a reference to a volatile field will not be treated as volatile
        private void RunAndMarkDone(SBThreadPool pool)
        {
            Run(pool);
            Interlocked.Increment(ref finishedVar);
        }
Esempio n. 5
0
 public sealed override void Run(SBThreadPool pool)
 {
     loopRun.ThreadRunIterations();
 }