| 17 | } |
| 18 | |
| 19 | concurrencpp::result<void> read_file_lines(const std::filesystem::path& path, |
| 20 | std::shared_ptr<concurrencpp::thread_pool_executor> background_executor, |
| 21 | std::shared_ptr<concurrencpp::thread_pool_executor> thread_pool_executor) { |
| 22 | // make sure we don't block in a thread that is used for cpu-processing |
| 23 | co_await concurrencpp::resume_on(background_executor); |
| 24 | |
| 25 | std::ifstream stream(path.c_str(), std::ios::binary | std::ios::in); |
| 26 | std::string file_content(std::istreambuf_iterator<char>(stream), {}); |
| 27 | |
| 28 | // make sure we don't process cpu-bound tasks on the background executor |
| 29 | co_await concurrencpp::resume_on(thread_pool_executor); |
| 30 | |
| 31 | for (const auto& line : read_lines(file_content)) { |
| 32 | std::cout << "read a new line. size: " << line.size() << std::endl; |
| 33 | std::cout << "line: " << std::endl; |
| 34 | std::cout << line; |
| 35 | std::cout << "\n==============" << std::endl; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | int main(const int argc, const char* argv[]) { |
| 40 | if (argc < 2) { |
no test coverage detected