MCPcopy Create free account
hub / github.com/David-Haim/concurrencpp / read_file_lines

Function read_file_lines

example/13_generator/source/main.cpp:19–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17}
18
19concurrencpp::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
39int main(const int argc, const char* argv[]) {
40 if (argc < 2) {

Callers 1

mainFunction · 0.85

Calls 3

resume_onFunction · 0.85
read_linesFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected