/// <summary>
        ///     Begin a parallel transformation chain by consuming any <see cref="IEnumerable{T}" />.
        /// </summary>
        /// <remarks>
        ///     This method will use a default number of threads which is almost certainly sub-optimal.
        ///     Manually test several different thread counts for each step in order to optimize your transformation chain.
        ///     Generally IO bound steps should have more threads as they are going to be idle waiting on IO rather than consuming
        ///     CPU.
        ///     Generally CPU bound steps should have fewer threads as those threads are going to be idle much less.
        /// </remarks>
        /// <typeparam name="TProduce">The type of item produced by this transformation.</typeparam>
        /// <typeparam name="TConsume">The type of item consumed by this transformation.</typeparam>
        /// <param name="source">An enumerable of the initial objects.</param>
        /// <param name="transform">The delegate that performs the transformations.</param>
        /// <returns>An <see cref="ITransformer{TProduce, TConsume}" /> suitable for parallel processing of transformation steps.</returns>
        public static ITransformer <TProduce, TConsume> BeginTransformMany <TProduce, TConsume>(this IEnumerable <TConsume> source, TransformMany <TProduce, TConsume> transform)
        {
            // Turn the source into an IProcuderConsumerCollection
            var consume = CastOrWrap(source);

            // Create a thread-safe producer consumer from this enumerable
            return(new TransformerMany <TProduce, TConsume>(consume, transform));
        }
Beispiel #2
0
 /// <summary>
 ///     Add a new transformation to a chain.
 /// </summary>
 public static ITransformer <TProduce, TConsume> ThenTransformMany <TProduce, TConsume, TOriginal>(this ITransformer <TConsume, TOriginal> transformer, TransformMany <TProduce, TConsume> transform, int threads)
 {
     return(new TransformerMany <TProduce, TConsume>(transformer.Produce, transform, transformer, threads));
 }
Beispiel #3
0
 /// <summary>
 ///     Creates a new TransformerMany instance.
 /// </summary>
 public TransformerMany(IProducerConsumerCollection <TConsume> consume, TransformMany <TProduce, TConsume> transform, ITransformer dependentTransformer, int threads)
     : base(consume, dependentTransformer, threads)
 {
     _transform = transform;
 }
Beispiel #4
0
 /// <summary>
 ///     Creates a new TransformerMany instance.
 /// </summary>
 public TransformerMany(IProducerConsumerCollection <TConsume> consume, TransformMany <TProduce, TConsume> transform, ITransformer dependentTransformer)
     : this(consume, transform, dependentTransformer, dependentTransformer.ThreadCount)
 {
 }
Beispiel #5
0
 /// <summary>
 ///     Creates a new TransformerMany instance.
 /// </summary>
 public TransformerMany(IProducerConsumerCollection <TConsume> consume, TransformMany <TProduce, TConsume> transform, int threads)
     : this(consume, transform, null, threads)
 {
 }
Beispiel #6
0
 /// <summary>
 ///     Creates a new TransformerMany instance.
 /// </summary>
 public TransformerMany(IProducerConsumerCollection <TConsume> consume, TransformMany <TProduce, TConsume> transform)
     : this(consume, transform, null, DefaultThreadCount)
 {
 }