| 140 | } |
| 141 | |
| 142 | int main() { |
| 143 | std::vector<FileName> Files = { |
| 144 | "demo_example/Input/1.txt", "demo_example/Input/2.txt", |
| 145 | "demo_example/Input/3.txt", "demo_example/Input/4.txt", |
| 146 | "demo_example/Input/5.txt", "demo_example/Input/6.txt", |
| 147 | "demo_example/Input/7.txt", "demo_example/Input/8.txt", |
| 148 | "demo_example/Input/9.txt", "demo_example/Input/10.txt", |
| 149 | }; |
| 150 | |
| 151 | std::cout << "Calculating char counts synchronously.\n"; |
| 152 | auto ResSync = CountCharInFiles(Files, 'x'); |
| 153 | std::cout << "Files contain " << ResSync << " 'x' chars.\n"; |
| 154 | |
| 155 | executors::SimpleExecutor executor(4); |
| 156 | Promise<Unit> p; |
| 157 | auto future = p.getFuture(); |
| 158 | |
| 159 | std::cout << "Calculating char counts asynchronously by future.\n"; |
| 160 | auto f = std::move(future).via(&executor).thenTry([&Files](auto &&) { |
| 161 | return CountCharInFilesAsync(Files, 'x').thenValue([](auto &&Value) { |
| 162 | std::cout << "Files contain " << Value << " 'x' chars.\n"; |
| 163 | }); |
| 164 | }); |
| 165 | |
| 166 | p.setValue(Unit()); |
| 167 | f.wait(); |
| 168 | |
| 169 | std::cout << "Calculating char counts asynchronously by coroutine.\n"; |
| 170 | auto ResCoro = syncAwait(CountCharInFilesCoro(Files, 'x'), &executor); |
| 171 | std::cout << "Files contain " << ResCoro << " 'x' chars.\n"; |
| 172 | |
| 173 | return 0; |
| 174 | } |
nothing calls this directly
no test coverage detected