@@ -557,23 +557,6 @@ protected override void Dispose(bool disposing)
557557 if ( _disposed )
558558 return ;
559559
560- if ( disposing )
561- {
562- _toProduceChannel . Writer . Complete ( ) ;
563- _producerTask . Wait ( ) ;
564-
565- // Complete the channel after the producerTask has finished, since producerTask could
566- // have posted more items to _toConsumeChannel.
567- _toConsumeChannel . Writer . Complete ( ) ;
568-
569- // Drain both BufferBlocks - this prevents what appears to be memory leaks when using the VS Debugger
570- // because if a BufferBlock still contains items, its underlying Tasks are not getting completed.
571- // See https://github.com/dotnet/corefx/issues/30582 for the VS Debugger issue.
572- // See also https://github.com/dotnet/machinelearning/issues/4399
573- //_toProduceChannel.Reader.ReadAsync();
574- //_toConsumeChannel.Reader.ReadAsync();
575- }
576-
577560 _disposed = true ;
578561 base . Dispose ( disposing ) ;
579562 }
@@ -660,18 +643,21 @@ protected override bool MoveNextCore()
660643 while ( _liveCount < _poolRows && ! _doneConsuming )
661644 {
662645 // We are under capacity. Try to get some more.
663- _toConsumeChannel . Reader . TryRead ( out int got ) ;
664- if ( got == 0 )
646+ var hasReadItem = _toConsumeChannel . Reader . TryRead ( out int got ) ;
647+ if ( hasReadItem )
665648 {
666- // We've reached the end of the Channel. There's no reason
667- // to attempt further communication with the producer.
668- // Check whether something horrible happened.
669- if ( _producerTaskException != null )
670- throw Ch . Except ( _producerTaskException , "Shuffle input cursor reader failed with an exception" ) ;
671- _doneConsuming = true ;
672- break ;
649+ if ( got == 0 )
650+ {
651+ // We've reached the end of the Channel. There's no reason
652+ // to attempt further communication with the producer.
653+ // Check whether something horrible happened.
654+ if ( _producerTaskException != null )
655+ throw Ch . Except ( _producerTaskException , "Shuffle input cursor reader failed with an exception" ) ;
656+ _doneConsuming = true ;
657+ break ;
658+ }
659+ _liveCount += got ;
673660 }
674- _liveCount += got ;
675661 }
676662 if ( _liveCount == 0 )
677663 return false ;
0 commit comments