Example #1
0
        public static List <AsyncTask> Foreach <T>(IList <T> upperBound, Action <T, int> action, bool wait = false, ParallelForScheduler scheduler = ParallelForScheduler.Block)
        {
            Action <int, CancellationTokenSource, int> actionProxy = (i, dummy, id) =>
            {
                action(upperBound[i], id);
            };

            switch (scheduler)
            {
            default:
            case ParallelForScheduler.Block: return(new Parallelx().BlockPartitionFor(0, upperBound.Count, actionProxy, null, wait));

            case ParallelForScheduler.Cyclic: return(new Parallelx().CyclicPartitionFor(0, upperBound.Count, actionProxy, null, wait));

            case ParallelForScheduler.RuntimeLoadBalance: return(new Parallelx().RuntimeLoadBalanceFor(0, upperBound.Count, actionProxy, null, wait));
            }
        }
Example #2
0
        public static List <AsyncTask> For(int upperBound, Action <int> action, bool wait = false, ParallelForScheduler scheduler = ParallelForScheduler.Block)
        {
            switch (scheduler)
            {
            default:
            case ParallelForScheduler.Block: return(new Parallelx().BlockPartitionFor(upperBound, action, wait));

            case ParallelForScheduler.Cyclic: return(new Parallelx().CyclicPartitionFor(upperBound, action, wait));

            case ParallelForScheduler.RuntimeLoadBalance: return(new Parallelx().RuntimeLoadBalanceFor(upperBound, action, wait));
            }
        }