Пример #1
0
 /// <summary>
 /// Executes a <c>for</c> (<c>For</c> in Visual Basic) loop with thread-local data in which iterations are run sequentially when the debugger is attached or in parallel otherwise,
 /// loop options can be configured,
 /// and the state of the loop can be monitored and manipulated.
 /// </summary>
 /// <typeparam name="TLocal">The type of the thread-local data.</typeparam>
 /// <param name="fromInclusive">The start index, inclusive.</param>
 /// <param name="toExclusive">The end index, exclusive.</param>
 /// <param name="parallelOptions">An object that configures the behavior of this operation.</param>
 /// <param name="localInit">The function delegate that returns the initial state of the local data for each task.</param>
 /// <param name="body">The delegate that is invoked once per iteration.</param>
 /// <param name="localFinally">The delegate that performs a final action on the local state of each task.</param>
 /// <returns>A structure that contains information about which portion of the loop completed.</returns>
 public static ParallelLoopResult For <TLocal>(int fromInclusive, int toExclusive, ParallelOptions parallelOptions, Func <TLocal> localInit, Func <int, ParallelLoopState, TLocal, TLocal> body, Action <TLocal> localFinally) =>
 IsParallel?
 Parallel.For(fromInclusive, toExclusive, parallelOptions, localInit, body, localFinally) :
     Sequential.For(fromInclusive, toExclusive, parallelOptions, localInit, body, localFinally);
Пример #2
0
 /// <summary>
 /// Executes a <c>foreach</c> (<c>For Each</c> in Visual Basic) operation with 64-bit indexes and with thread-local data on a <see cref="OrderablePartitioner{TSource}"/> in which iterations are run sequentially when the debugger is attached or in parallel otherwise,
 /// loop options can be configured,
 /// and the state of the loop can be monitored and manipulated.
 /// </summary>
 /// <typeparam name="TSource">The type of the elements in source.</typeparam>
 /// <typeparam name="TLocal">The type of the thread-local data.</typeparam>
 /// <param name="source">The orderable partitioner that contains the original data source.</param>
 /// <param name="parallelOptions">An object that configures the behavior of this operation.</param>
 /// <param name="localInit">The function delegate that returns the initial state of the local data for each task.</param>
 /// <param name="body">The delegate that is invoked once per iteration.</param>
 /// <param name="localFinally">The delegate that performs a final action on the local state of each task.</param>
 /// <returns>A structure that contains information about which portion of the loop completed.</returns>
 public static ParallelLoopResult ForEach <TSource, TLocal>(OrderablePartitioner <TSource> source, ParallelOptions parallelOptions, Func <TLocal> localInit, Func <TSource, ParallelLoopState, long, TLocal, TLocal> body, Action <TLocal> localFinally) =>
 IsParallel?
 Parallel.ForEach(source, parallelOptions, localInit, body, localFinally) :
     Sequential.ForEach(source, parallelOptions, localInit, body, localFinally);
Пример #3
0
 /// <summary>
 /// Executes a <c>for</c> (<c>For</c> in Visual Basic) loop with 64-bit indexes and thread-local data in which iterations are run sequentially when the debugger is attached or in parallel otherwise,
 /// and the state of the loop can be monitored and manipulated.
 /// </summary>
 /// <typeparam name="TLocal">The type of the thread-local data.</typeparam>
 /// <param name="fromInclusive">The start index, inclusive.</param>
 /// <param name="toExclusive">The end index, exclusive.</param>
 /// <param name="localInit">The function delegate that returns the initial state of the local data for each task.</param>
 /// <param name="body">The delegate that is invoked once per iteration.</param>
 /// <param name="localFinally">The delegate that performs a final action on the local state of each task.</param>
 /// <returns>A structure that contains information about which portion of the loop completed.</returns>
 public static ParallelLoopResult For <TLocal>(long fromInclusive, long toExclusive, Func <TLocal> localInit, Func <long, ParallelLoopState, TLocal, TLocal> body, Action <TLocal> localFinally) =>
 IsParallel?
 Parallel.For(fromInclusive, toExclusive, localInit, body, localFinally) :
     Sequential.For(fromInclusive, toExclusive, localInit, body, localFinally);
Пример #4
0
 /// <summary>
 /// Executes a <c>foreach</c> (<c>For Each</c> in Visual Basic) operation on a <see cref="Partitioner{TSource}"/> in which iterations are run sequentially when the debugger is attached or in parallel otherwise,
 /// loop options can be configured,
 /// and the state of the loop can be monitored and manipulated.
 /// </summary>
 /// <typeparam name="TSource">The type of the elements in source.</typeparam>
 /// <param name="source">The partitioner that contains the original data source.</param>
 /// <param name="body">The delegate that is invoked once per iteration.</param>
 /// <returns>A structure that contains information about which portion of the loop completed.</returns>
 public static ParallelLoopResult ForEach <TSource>(Partitioner <TSource> source, Action <TSource, ParallelLoopState> body) =>
 IsParallel?
 Parallel.ForEach(source, body) :
     Sequential.ForEach(source, body);
Пример #5
0
 /// <summary>
 /// Executes a <c>foreach</c> (<c>For Each</c> in Visual Basic) operation on a <see cref="OrderablePartitioner{TSource}"/> in which iterations are run sequentially when the debugger is attached or in parallel otherwise,
 /// loop options can be configured,
 /// and the state of the loop can be monitored and manipulated.
 /// </summary>
 /// <typeparam name="TSource">The type of the elements in source.</typeparam>
 /// <param name="source">The orderable partitioner that contains the original data source.</param>
 /// <param name="parallelOptions">An object that configures the behavior of this operation.</param>
 /// <param name="body">The delegate that is invoked once per iteration.</param>
 /// <returns>A structure that contains information about which portion of the loop completed.</returns>
 public static ParallelLoopResult ForEach <TSource>(OrderablePartitioner <TSource> source, ParallelOptions parallelOptions, Action <TSource, ParallelLoopState, long> body) =>
 IsParallel?
 Parallel.ForEach(source, parallelOptions, body) :
     Sequential.ForEach(source, parallelOptions, body);
Пример #6
0
 /// <summary>
 /// Executes a <c>foreach</c> (<c>For Each</c> in Visual Basic) operation with 64-bit indexes on an <see cref="IEnumerable{T}"/> in which iterations are run sequentially when the debugger is attached or in parallel otherwise,
 /// loop options can be configured,
 /// and the state of the loop can be monitored and manipulated.
 /// </summary>
 /// <typeparam name="TSource">The type of the data in the source.</typeparam>
 /// <param name="source">An enumerable data source.</param>
 /// <param name="body">The delegate that is invoked once per iteration.</param>
 /// <returns>A structure that contains information about which portion of the loop completed.</returns>
 public static ParallelLoopResult ForEach <TSource>(IEnumerable <TSource> source, Action <TSource, ParallelLoopState, long> body) =>
 IsParallel?
 Parallel.ForEach(source, body) :
     Sequential.ForEach(source, body);
Пример #7
0
 /// <summary>
 /// Executes a <c>foreach</c> (<c>For Each</c> in Visual Basic) operation with thread-local data and 64-bit indexes on an <see cref="IEnumerable{T}"/> in which iterations are run sequentially when the debugger is attached or in parallel otherwise,
 /// loop options can be configured,
 /// and the state of the loop can be monitored and manipulated.
 /// </summary>
 /// <typeparam name="TSource">The type of the data in the source.</typeparam>
 /// <typeparam name="TLocal">The type of the thread-local data.</typeparam>
 /// <param name="source">An enumerable data source.</param>
 /// <param name="localInit">The function delegate that returns the initial state of the local data for each task.</param>
 /// <param name="body">The delegate that is invoked once per iteration.</param>
 /// <param name="localFinally">The delegate that performs a final action on the local state of each task.</param>
 /// <returns>A structure that contains information about which portion of the loop completed.</returns>
 public static ParallelLoopResult ForEach <TSource, TLocal>(IEnumerable <TSource> source, Func <TLocal> localInit, Func <TSource, ParallelLoopState, long, TLocal, TLocal> body, Action <TLocal> localFinally) =>
 IsParallel?
 Parallel.ForEach(source, localInit, body, localFinally) :
     Sequential.ForEach(source, localInit, body, localFinally);
Пример #8
0
 /// <summary>
 /// Executes a <c>foreach</c> (<c>For Each</c> in Visual Basic) operation on an <see cref="IEnumerable{T}"/> in which iterations are run sequentially when the debugger is attached or in parallel otherwise.
 /// </summary>
 /// <typeparam name="TSource">The type of the data in the source.</typeparam>
 /// <param name="source">An enumerable data source.</param>
 /// <param name="parallelOptions">An object that configures the behavior of this operation.</param>
 /// <param name="body">The delegate that is invoked once per iteration.</param>
 /// <returns>A structure that contains information about which portion of the loop completed.</returns>
 public static ParallelLoopResult ForEach <TSource>(IEnumerable <TSource> source, ParallelOptions parallelOptions, Action <TSource> body) =>
 IsParallel?
 Parallel.ForEach(source, parallelOptions, body) :
     Sequential.ForEach(source, parallelOptions, body);
Пример #9
0
 /// <summary>
 /// Executes a <c>for</c> (<c>For</c> in Visual Basic) loop with 64-bit indexes in which iterations are run sequentially when the debugger is attached or in parallel otherwise,
 /// loop options can be configured,
 /// and the state of the loop can be monitored and manipulated.
 /// </summary>
 /// <param name="fromInclusive">The start index, inclusive.</param>
 /// <param name="toExclusive">The end index, exclusive.</param>
 /// <param name="parallelOptions">An object that configures the behavior of this operation.</param>
 /// <param name="body">The delegate that is invoked once per iteration.</param>
 /// <returns>A structure that contains information about which portion of the loop completed.</returns>
 public static ParallelLoopResult For(long fromInclusive, long toExclusive, ParallelOptions parallelOptions, Action <long, ParallelLoopState> body) =>
 IsParallel?
 Parallel.For(fromInclusive, toExclusive, parallelOptions, body) :
     Sequential.For(fromInclusive, toExclusive, parallelOptions, body);
Пример #10
0
 /// <summary>
 /// Executes a <c>for</c> (<c>For</c> in Visual Basic) loop in which iterations are run sequentially when the debugger is attached or in parallel otherwise,
 /// and the state of the loop can be monitored and manipulated.
 /// </summary>
 /// <param name="fromInclusive">The start index, inclusive.</param>
 /// <param name="toExclusive">The end index, exclusive.</param>
 /// <param name="body">The delegate that is invoked once per iteration.</param>
 /// <returns>A structure that contains information about which portion of the loop completed.</returns>
 public static ParallelLoopResult For(int fromInclusive, int toExclusive, Action <int, ParallelLoopState> body) =>
 IsParallel?
 Parallel.For(fromInclusive, toExclusive, body) :
     Sequential.For(fromInclusive, toExclusive, body);
Пример #11
0
 /// <summary>
 /// Executes a <c>for</c> (<c>For</c> in Visual Basic) loop in which iterations are run sequentially when the debugger is attached or in parallel otherwise,
 /// and loop options can be configured.
 /// </summary>
 /// <param name="fromInclusive">The start index, inclusive.</param>
 /// <param name="toExclusive">The end index, exclusive.</param>
 /// <param name="parallelOptions">An object that configures the behavior of this operation.</param>
 /// <param name="body">The delegate that is invoked once per iteration.</param>
 /// <returns>A structure that contains information about which portion of the loop completed.</returns>
 public static ParallelLoopResult For(int fromInclusive, int toExclusive, ParallelOptions parallelOptions, Action <int> body) =>
 IsParallel?
 Parallel.For(fromInclusive, toExclusive, parallelOptions, body) :
     Sequential.For(fromInclusive, toExclusive, parallelOptions, body);
Пример #12
0
 /// <summary>
 /// Executes a <c>for</c> (<c>For</c> in Visual Basic) loop with 64-bit indexes in which iterations are run sequentially when the debugger is attached or in parallel otherwise.
 /// </summary>
 /// <param name="fromInclusive">The start index, inclusive.</param>
 /// <param name="toExclusive">The end index, exclusive.</param>
 /// <param name="body">The delegate that is invoked once per iteration.</param>
 /// <returns>A structure that contains information about which portion of the loop completed.</returns>
 public static ParallelLoopResult For(long fromInclusive, long toExclusive, Action <long> body) =>
 IsParallel?
 Parallel.For(fromInclusive, toExclusive, body) :
     Sequential.For(fromInclusive, toExclusive, body);