Return whether the generator was closed or destroyed.
| 924 | |
| 925 | /// Return whether the generator was closed or destroyed. |
| 926 | bool is_closed() const { |
| 927 | auto state = weak_state_.lock(); |
| 928 | if (!state) { |
| 929 | // Generator was destroyed |
| 930 | return true; |
| 931 | } |
| 932 | auto lock = state->mutex.Lock(); |
| 933 | return state->finished; |
| 934 | } |
| 935 | |
| 936 | private: |
| 937 | const std::weak_ptr<State> weak_state_; |