| 34 | |
| 35 | template <typename T> |
| 36 | AsyncGenerator<T> FailAt(AsyncGenerator<T> src, int failing_index) { |
| 37 | auto index = std::make_shared<std::atomic<int>>(0); |
| 38 | return [src, index, failing_index]() { |
| 39 | auto idx = index->fetch_add(1); |
| 40 | if (idx >= failing_index) { |
| 41 | return Future<T>::MakeFinished(Status::Invalid("XYZ")); |
| 42 | } |
| 43 | return src(); |
| 44 | }; |
| 45 | } |
| 46 | |
| 47 | template <typename T> |
| 48 | AsyncGenerator<T> SlowdownABit(AsyncGenerator<T> source) { |