/// <summary> /// Initializes a new instance of the <see cref="ProducerConsumerProcessor{TItem}"/> class. /// </summary> /// <param name="name">The name of the processor.</param> /// <param name="cancellationSourceFactory">The factory for creating cancellation sources.</param> /// <param name="producerEngines">The engines which will produce objects to process.</param> /// <param name="consumerEngine">The consumer engine which will consume objects which were produced.</param> public ProducerConsumerProcessor(string name, ICancellationSourceFactory cancellationSourceFactory, IEnumerable <IProducerEngine <TItem> > producerEngines, IConsumerEngine <TItem> consumerEngine) : base(name) { this.cancellationSourceFactory = cancellationSourceFactory ?? throw new ArgumentNullException(nameof(cancellationSourceFactory)); this.producerEngines = producerEngines ?? throw new ArgumentNullException(nameof(producerEngines)); this.consumerEngine = consumerEngine ?? throw new ArgumentNullException(nameof(consumerEngine)); }
/// <summary> /// Optionally stops the engine if the engine is an asynchronous consumer engine. /// </summary> /// <param name="engine">The consumer engine.</param> /// <returns>The task being used to stop the engine, otherwise a completed task if no task was required.</returns> public static Task StopIfAsynchronous <TItem>(this IConsumerEngine <TItem> engine) { if (engine == null) { throw new ArgumentNullException(nameof(engine)); } return((engine as IStoppable)?.StopAsync() ?? Task.CompletedTask); }
public AppMangerService(IEngine engine, IConsumerEngine consumerEngine) { _engine = engine; _consumerEngine = consumerEngine; }