Преглед изворни кода

EAGLESIX-3077: Added code for interrupt as suggested per PR

David Aebersold пре 11 година
родитељ
комит
f027344447
1 измењених фајлова са 3 додато и 0 уклоњено
  1. 3 0
      lib/pipeline/documentSources/LimitDocumentSource.js

+ 3 - 0
lib/pipeline/documentSources/LimitDocumentSource.js

@@ -52,6 +52,9 @@ proto.coalesce = function coalesce(nextSource) {
 proto.getNext = function getNext(callback) {
 	if (!callback) throw new Error(this.getSourceName() + ' #getNext() requires callback');
 
+	if (this.expCtx instanceof Object && this.expCtx.checkForInterrupt && this.expCtx.checkForInterrupt() === false)
+		return callback(new Error("Interrupted"));
+
 	if (++this.count > this.limit) {
 		this.source.dispose();
 		callback(null, DocumentSource.EOF);