| 73 | } |
| 74 | |
| 75 | void Uthread_async(benchmark::State& state) { |
| 76 | async_simple::executors::SimpleExecutor executor(10); |
| 77 | auto test = [&]() { |
| 78 | auto Job = [&]() -> Future<int> { |
| 79 | Promise<int> p; |
| 80 | auto f = p.getFuture().via(&executor); |
| 81 | delayedTask( |
| 82 | &executor, |
| 83 | [p = std::move(p)]() mutable { |
| 84 | auto value = 1024; |
| 85 | p.setValue(value); |
| 86 | }, |
| 87 | 100); |
| 88 | return f; |
| 89 | }; |
| 90 | |
| 91 | constexpr size_t n = 10; |
| 92 | std::atomic<int> running = n; |
| 93 | |
| 94 | for (size_t i = 0; i < n; i++) |
| 95 | async<Launch::Schedule>( |
| 96 | [&running, &Job]() { |
| 97 | await(Job()); |
| 98 | running--; |
| 99 | }, |
| 100 | &executor); |
| 101 | |
| 102 | while (running) { |
| 103 | } |
| 104 | }; |
| 105 | |
| 106 | for ([[maybe_unused]] const auto& _ : state) |
| 107 | test(); |
| 108 | } |
| 109 | |
| 110 | void Uthread_await(benchmark::State& state) { |
| 111 | async_simple::executors::SimpleExecutor executor(10); |
nothing calls this directly
no test coverage detected