| 662 | : state_(std::make_shared<State>(std::move(future))) {} |
| 663 | |
| 664 | Future<T> operator()() { |
| 665 | if (state_->source_) { |
| 666 | return state_->source_(); |
| 667 | } else { |
| 668 | auto state = state_; |
| 669 | return state_->future_.Then([state](const AsyncGenerator<T>& source) { |
| 670 | state->source_ = source; |
| 671 | return state->source_(); |
| 672 | }); |
| 673 | } |
| 674 | } |
| 675 | |
| 676 | private: |
| 677 | struct State { |