Parallel.cs
Go to the documentation of this file.
43 return Math.Min (Environment.ProcessorCount, (scheduler ?? TaskScheduler.Current).MaximumConcurrencyLevel);
85 TaskCreationOptions creation = TaskCreationOptions.LongRunning | TaskCreationOptions.AttachedToParent;
91 tasks [i] = Task.Factory.StartNew (action, options.CancellationToken, creation, options.TaskScheduler);
102 public static ParallelLoopResult For (int fromInclusive, int toExclusive, Action<int, ParallelLoopState> body)
107 public static ParallelLoopResult For (int fromInclusive, int toExclusive, ParallelOptions parallelOptions, Action<int> body)
112 public static ParallelLoopResult For (int fromInclusive, int toExclusive, ParallelOptions parallelOptions, Action<int, ParallelLoopState> body)
114 return For<object> (fromInclusive, toExclusive, parallelOptions, () => null, (i, s, l) => { body (i, s); return null; }, _ => {});
123 return For<TLocal> (fromInclusive, toExclusive, ParallelOptions.Default, localInit, body, localFinally);
198 stopIndex = extWorker + 1 == num ? toExclusive : Math.Min (toExclusive, fromInclusive + (extWorker + 1) * step);
241 return new ParallelLoopResult (infos.LowestBreakIteration, !(infos.IsStopped || infos.IsExceptional));
275 public static ParallelLoopResult For (long fromInclusive, long toExclusive, Action<long, ParallelLoopState> body)
281 public static ParallelLoopResult For (long fromInclusive, long toExclusive, ParallelOptions parallelOptions, Action<long> body)
287 public static ParallelLoopResult For (long fromInclusive, long toExclusive, ParallelOptions parallelOptions, Action<long, ParallelLoopState> body)
289 return For<object> (fromInclusive, toExclusive, parallelOptions, () => null, (i, s, l) => { body (i, s); return null; }, _ => {});
299 return For<TLocal> (fromInclusive, toExclusive, ParallelOptions.Default, localInit, body, localFinally);
328 internal static ParallelLoopResult ForEach<TSource, TLocal> (Func<int, IList<IEnumerator<TSource>>> enumerable, ParallelOptions options,
344 options != null && options.MaxDegreeOfParallelism != -1 ? options.MaxDegreeOfParallelism : int.MaxValue);
409 return new ParallelLoopResult (infos.LowestBreakIteration, !(infos.IsStopped || infos.IsExceptional));
412 public static ParallelLoopResult ForEach<TSource> (IEnumerable<TSource> source, Action<TSource> body)
426 public static ParallelLoopResult ForEach<TSource> (IEnumerable<TSource> source, Action<TSource, ParallelLoopState> body)
513 public static ParallelLoopResult ForEach<TSource> (IEnumerable<TSource> source, ParallelOptions parallelOptions,
528 public static ParallelLoopResult ForEach<TSource> (IEnumerable<TSource> source, ParallelOptions parallelOptions,
543 public static ParallelLoopResult ForEach<TSource> (OrderablePartitioner<TSource> source, ParallelOptions parallelOptions,
557 public static ParallelLoopResult ForEach<TSource> (Partitioner<TSource> source, ParallelOptions parallelOptions,
570 public static ParallelLoopResult ForEach<TSource> (Partitioner<TSource> source, ParallelOptions parallelOptions,
580 public static ParallelLoopResult ForEach<TSource, TLocal> (IEnumerable<TSource> source, Func<TLocal> localInit,
594 public static ParallelLoopResult ForEach<TSource, TLocal> (IEnumerable<TSource> source, Func<TLocal> localInit,
605 public static ParallelLoopResult ForEach<TSource, TLocal> (OrderablePartitioner<TSource> source, Func<TLocal> localInit,
609 return ForEach<TSource, TLocal> (source, ParallelOptions.Default, localInit, body, localFinally);
612 public static ParallelLoopResult ForEach<TSource, TLocal> (Partitioner<TSource> source, Func<TLocal> localInit,
616 return ForEach<TSource, TLocal> (source, ParallelOptions.Default, localInit, body, localFinally);
619 public static ParallelLoopResult ForEach<TSource, TLocal> (IEnumerable<TSource> source, ParallelOptions parallelOptions,
627 return ForEach<TSource, TLocal> (Partitioner.Create (source), parallelOptions, localInit, body, localFinally);
630 public static ParallelLoopResult ForEach<TSource, TLocal> (IEnumerable<TSource> source, ParallelOptions parallelOptions,
638 return ForEach<TSource, TLocal> (Partitioner.Create (source), parallelOptions, localInit, body, localFinally);
641 public static ParallelLoopResult ForEach<TSource, TLocal> (Partitioner<TSource> source, ParallelOptions parallelOptions,
651 return ForEach<TSource, TLocal> (source.GetPartitions, parallelOptions, localInit, body, localFinally);
654 public static ParallelLoopResult ForEach<TSource, TLocal> (OrderablePartitioner<TSource> source, ParallelOptions parallelOptions,
static ParallelLoopResult For(long fromInclusive, long toExclusive, ParallelOptions parallelOptions, Action< long > body)
Definition: Parallel.cs:281
abstract IList< IEnumerator< KeyValuePair< long, TSource > > > GetOrderablePartitions(int partitionCount)
void Add(int index, T value)
Definition: SimpleConcurrentBag.cs:84
int GetNextIndex()
Definition: SimpleConcurrentBag.cs:52
static TaskScheduler Current
Definition: TaskScheduler.cs:86
void ThrowIfCancellationRequested()
Definition: CancellationToken.cs:86
static ParallelLoopResult For(long fromInclusive, long toExclusive, ParallelOptions parallelOptions, Action< long, ParallelLoopState > body)
Definition: Parallel.cs:287
Definition: ConfiguredTaskAwaitable.cs:33
Definition: AggregateException.cs:31
static ParallelLoopResult For< TLocal >(int fromInclusive, int toExclusive, Func< TLocal > localInit, Func< int, ParallelLoopState, TLocal, TLocal > body, Action< TLocal > localFinally)
Definition: Parallel.cs:117
static void Invoke(ParallelOptions parallelOptions, params Action[] actions)
Definition: Parallel.cs:681
int MaxDegreeOfParallelism
Definition: ParallelOptions.cs:50
TaskScheduler TaskScheduler
Definition: ParallelOptions.cs:55
static ParallelLoopResult For(int fromInclusive, int toExclusive, Action< int, ParallelLoopState > body)
Definition: Parallel.cs:102
static ParallelLoopResult For(long fromInclusive, long toExclusive, Action< long, ParallelLoopState > body)
Definition: Parallel.cs:275
bool TryTake(int index, out T value)
Definition: SimpleConcurrentBag.cs:57
static ParallelLoopResult For(int fromInclusive, int toExclusive, Action< int > body)
Definition: Parallel.cs:97
static ParallelLoopResult For(long fromInclusive, long toExclusive, Action< long > body)
Definition: Parallel.cs:269
static ParallelLoopResult ForEach< TSource >(IEnumerable< TSource > source, Action< TSource > body)
Definition: Parallel.cs:412
bool TrySteal(int index, out T value)
Definition: SimpleConcurrentBag.cs:64
static void Invoke(params Action[] actions)
Definition: Parallel.cs:673
Definition: IStructuralComparable.cs:33
static ParallelLoopResult For(int fromInclusive, int toExclusive, ParallelOptions parallelOptions, Action< int > body)
Definition: Parallel.cs:107
static ParallelLoopResult For(int fromInclusive, int toExclusive, ParallelOptions parallelOptions, Action< int, ParallelLoopState > body)
Definition: Parallel.cs:112
Definition: Parallel.cs:34
Definition: AotInterlocked.cs:3
Definition: Task.cs:43
CancellationToken CancellationToken
Definition: ParallelOptions.cs:45