| 97 | } |
| 98 | |
| 99 | Future<uint64_t> CountCharInFilesAsync(const std::vector<FileName> &Files, |
| 100 | char c) { |
| 101 | // std::shared_ptr is necessary here. Since ReadSize may be used after |
| 102 | // CountCharInFilesAsync function ends. |
| 103 | auto ReadSize = std::make_shared<uint64_t>(0); |
| 104 | // We need to introduce another API `do_for_each` here. |
| 105 | return do_for_each(std::move(Files), |
| 106 | [ReadSize, c](auto &&File) { |
| 107 | return CountCharInFileAsyncImpl(File, c).thenValue( |
| 108 | [ReadSize](auto &&Size) { |
| 109 | *ReadSize += Size; |
| 110 | return makeReadyFuture(); |
| 111 | }); |
| 112 | }) |
| 113 | .thenTry([ReadSize](auto &&) { |
| 114 | return makeReadyFuture<uint64_t>(*ReadSize); |
| 115 | }); |
| 116 | ; |
| 117 | } |
| 118 | |
| 119 | ///////////////////////////////////////// |
| 120 | /////////// Coroutine Part ////////////// |
no test coverage detected