BEPUutilities2.Threading.ParallelLooper.ForLoop C# (CSharp) Метод

ForLoop() публичный Метод

Iterates over the interval.
public ForLoop ( int beginIndex, int endIndex, Action loopBody ) : void
beginIndex int Starting index of the iteration.
endIndex int Ending index of the iteration.
loopBody Action Function to call on each iteration.
Результат void
        public void ForLoop(int beginIndex, int endIndex, Action<int> loopBody)
        {
            //CANNOT CALL THIS WHILE BUSY!!!! ASSUME THAT IS GUARANTEED.
            //Compute intervals for each worker.

            workerCount = workers.Count;

            //TODO: The job splitting could be tuned possibly.
            int iterationCount = endIndex - beginIndex;
            int tasksPerThread = Math.Max(minimumTasksPerThread, iterationCount / maximumIterationsPerTask);
            int taskSubdivisions = workerCount * tasksPerThread;

            currentBeginIndex = beginIndex;
            currentEndIndex = endIndex;
            currentLoopBody = loopBody;
            iterationsPerSteal = Math.Max(1, iterationCount / taskSubdivisions);
            jobIndex = 0;
            float maxJobs = iterationCount / (float) iterationsPerSteal;
            if (maxJobs % 1 == 0)
                maxJobIndex = (int) maxJobs;
            else
                maxJobIndex = 1 + (int) maxJobs;

            for (int i = 0; i < workers.Count; i++)
            {
                workers[i].finalIndex = endIndex;
                workers[i].iterationsPerSteal = iterationsPerSteal;
                workers[i].getToWork.Set();
            }

            loopFinished.WaitOne();
        }