/// <summary> /// Start producing results for given context. /// Provided consumer is notified whenever progress is made /// (new value is ready or error occurs). /// </summary> public void ProduceResults( IConsumer <CloseableReference <CloseableImage> > consumer, IProducerContext context) { IProducerListener listener = context.Listener; IPostprocessor postprocessor = context.ImageRequest.Postprocessor; PostprocessorConsumer basePostprocessorConsumer = new PostprocessorConsumer(this, consumer, listener, context.Id, postprocessor, context); IConsumer <CloseableReference <CloseableImage> > postprocessorConsumer; if (postprocessor.GetType() == typeof(IRepeatedPostprocessor)) { postprocessorConsumer = new RepeatedPostprocessorConsumer( basePostprocessorConsumer, (IRepeatedPostprocessor)postprocessor, context); } else { postprocessorConsumer = new SingleUsePostprocessorConsumer(basePostprocessorConsumer); } _inputProducer.ProduceResults(postprocessorConsumer, context); }
internal RepeatedPostprocessorConsumer( PostprocessorConsumer postprocessorConsumer, IRepeatedPostprocessor repeatedPostprocessor, IProducerContext context) : base(postprocessorConsumer) { repeatedPostprocessor.SetCallback(this); context.AddCallbacks( new BaseProducerContextCallbacks( () => { if (Close()) { Consumer.OnCancellation(); } }, () => { }, () => { }, () => { })); }
internal SingleUsePostprocessorConsumer(PostprocessorConsumer postprocessorConsumer) : base(postprocessorConsumer) { }