| 563 | } |
| 564 | break; |
| 565 | } |
| 566 | case State::Destroying: |
| 567 | case State::Errored: break; |
| 568 | } |
| 569 | } |
| 570 | |
| 571 | Result AsyncReadableStream::finishedDestroyingReadable() |
| 572 | { |
| 573 | if (state != State::Destroying) |
| 574 | return Result::Error(AsyncStreamsResultCategory, AsyncStreamsError::InvalidReadableState); |
| 575 | state = State::Ended; |
| 576 | destroyed = true; |
| 577 | eventClose.emit(); |
| 578 | return Result(true); |
| 579 | } |
| 580 | |
| 581 | void AsyncReadableStream::executeRead() |
| 582 | { |
| 583 | state = State::Reading; |
| 584 | if (not readQueue.isEmpty()) |
| 585 | { |
| 586 | emitOnData(); |
| 587 | } |
| 588 | while (state == State::Reading) |
| 589 | { |
| 590 | const Result res = asyncRead(); |
| 591 | if (res) |
| 592 | { |
| 593 | switch (state) |
| 594 | { |
| 595 | case State::SyncReadMore: |
| 596 | // push + reactivate(true) have been called synchronously (inside this method) |
| 597 | state = State::Reading; |
| 598 | continue; // loop calling one more asyncRead |
| 599 | case State::Reading: |
| 600 | // push + reactivate(...) have not been called so this becomes an async call |
| 601 | state = State::AsyncReading; |
| 602 | break; |
| 603 | case State::SyncPushing: |
| 604 | state = State::Errored; |