@@ -405,8 +405,31 @@ class DataQueueFeeder final : public AsyncWrap {
405405
406406 void setDataQueue (std::shared_ptr<DataQueue> queue) { dataQueue_ = queue; }
407407
408- void tryWakePulls ();
409- void DrainAndClose ();
408+ void tryWakePulls () {
409+ if (!readFinish_.IsEmpty ()) {
410+ Local<Promise::Resolver> resolver = readFinish_.Get (env ()->isolate ());
411+ // I do not think, that this can error...
412+ (void )resolver->Resolve (env ()->context (), v8::True (env ()->isolate ()));
413+ readFinish_.Reset ();
414+ }
415+ }
416+
417+ void DrainAndClose () {
418+ if (done) return ;
419+ done = true ;
420+ // do not do this several time, and note,
421+ // it may be called several times.
422+ while (!pendingPulls_.empty ()) {
423+ auto & pending = pendingPulls_.front ();
424+ auto pop = OnScopeLeave ([this ] { pendingPulls_.pop_front (); });
425+ pending.next (bob::STATUS_EOS, nullptr , 0 , [](uint64_t ) {});
426+ }
427+ if (!readFinish_.IsEmpty ()) {
428+ Local<Promise::Resolver> resolver = readFinish_.Get (env ()->isolate ());
429+ (void )resolver->Resolve (env ()->context (), v8::False (env ()->isolate ()));
430+ readFinish_.Reset ();
431+ }
432+ }
410433
411434 struct PendingPull {
412435 Next next;
@@ -436,32 +459,6 @@ class DataQueueFeeder final : public AsyncWrap {
436459 bool done = false ;
437460};
438461
439- void DataQueueFeeder::tryWakePulls () {
440- if (!readFinish_.IsEmpty ()) {
441- Local<Promise::Resolver> resolver = readFinish_.Get (env ()->isolate ());
442- // I do not think, that this can error...
443- (void )resolver->Resolve (env ()->context (), v8::True (env ()->isolate ()));
444- readFinish_.Reset ();
445- }
446- }
447-
448- void DataQueueFeeder::DrainAndClose () {
449- if (done) return ;
450- done = true ;
451- // do not do this several time, and note,
452- // it may be called several times.
453- while (!pendingPulls_.empty ()) {
454- auto & pending = pendingPulls_.front ();
455- auto pop = OnScopeLeave ([this ] { pendingPulls_.pop_front (); });
456- pending.next (bob::STATUS_EOS, nullptr , 0 , [](uint64_t ) {});
457- }
458- if (!readFinish_.IsEmpty ()) {
459- Local<Promise::Resolver> resolver = readFinish_.Get (env ()->isolate ());
460- (void )resolver->Resolve (env ()->context (), v8::False (env ()->isolate ()));
461- readFinish_.Reset ();
462- }
463- }
464-
465462} // namespace node
466463
467464#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
0 commit comments