public ChunkedPhase( IStageIdentity stageIdentity, IGenerationPhaseIdentity phaseIdentity, IReadOnlyLargeCollection <TKey> chunkKeys, IAsyncFactory <TKey, IDisposableValue <TChunk> > chunkFactory, IChunkProcessor <TChunk> chunkProcessor, GenerationOptions options = null) : base(options?.CancellationToken ?? DefaultCancellationToken) { Contracts.Requires.That(stageIdentity != null); Contracts.Requires.That(phaseIdentity != null); Contracts.Requires.That(chunkKeys != null); Contracts.Requires.That(chunkFactory != null); Contracts.Requires.That(chunkProcessor != null); this.StageIdentity = stageIdentity; this.PhaseIdentity = phaseIdentity; this.chunkKeys = chunkKeys; this.chunkFactory = chunkFactory; this.chunkProcessor = chunkProcessor; this.Progress = this.progress.AsObservable(); var dataflowOptions = new ExecutionDataflowBlockOptions() { MaxDegreeOfParallelism = options?.MaxDegreeOfParallelism ?? DefaultMaxDegreeOfParallelism, CancellationToken = this.CancellationToken, }; this.processChunks = new ActionBlock <TKey>(this.ProcessChunk, dataflowOptions); this.chunksCompleted = new AsyncLongCountdownEvent(this.ProgressTotalCount); }
public StageGenerator(GenerationOptions options) : base(options?.CancellationToken ?? CancellationToken.None) { Contracts.Requires.That(options != null); var dataflowOptions = new ExecutionDataflowBlockOptions() { MaxDegreeOfParallelism = options.MaxDegreeOfParallelism, CancellationToken = this.CancellationToken, }; this.generator = new ActionBlock <IStageSeed>(this.HandleStageSeed, dataflowOptions); this.Progress = this.progress.AsObservable(); }