| 5 | #include "concurrencpp/concurrencpp.h" |
| 6 | |
| 7 | concurrencpp::generator<std::string_view> read_lines(std::string_view text) { |
| 8 | std::string_view::size_type pos = 0; |
| 9 | std::string_view::size_type prev = 0; |
| 10 | |
| 11 | while ((pos = text.find('\n', prev)) != std::string::npos) { |
| 12 | co_yield text.substr(prev, pos - prev); |
| 13 | prev = pos + 1; |
| 14 | } |
| 15 | |
| 16 | co_yield text.substr(prev); |
| 17 | } |
| 18 | |
| 19 | concurrencpp::result<void> read_file_lines(const std::filesystem::path& path, |
| 20 | std::shared_ptr<concurrencpp::thread_pool_executor> background_executor, |