| 183 | } |
| 184 | |
| 185 | auto main() -> int |
| 186 | { |
| 187 | // Create a thread pool and get a scheduler from it |
| 188 | exec::static_thread_pool pool{8}; |
| 189 | exec::async_scope scope; |
| 190 | ex::scheduler auto sched = pool.get_scheduler(); |
| 191 | |
| 192 | // Fake a couple of edge_detect requests |
| 193 | for (int i = 0; i < 3; i++) |
| 194 | { |
| 195 | // Create a test request |
| 196 | http_request req{.url_ = "/edge_detect", .headers_ = {}, .body_ = "scene"}; |
| 197 | |
| 198 | // The handler for the /edge_detect requests |
| 199 | ex::sender auto snd = handle_edge_detection_request(req); |
| 200 | |
| 201 | // Pack this into a simplified flow and execute it asynchronously |
| 202 | ex::sender auto action = std::move(snd) |
| 203 | | ex::then( |
| 204 | [](http_response resp) |
| 205 | { |
| 206 | std::ostringstream oss; |
| 207 | oss << "Sending response: " << resp.status_code_ << " / " |
| 208 | << resp.body_ << "\n"; |
| 209 | std::cout << oss.str(); |
| 210 | }); |
| 211 | scope.spawn(ex::starts_on(sched, std::move(action))); |
| 212 | } |
| 213 | |
| 214 | // Fake a couple of multi_blur requests |
| 215 | for (int i = 0; i < 3; i++) |
| 216 | { |
| 217 | // Create a test request |
| 218 | http_request req{.url_ = "/multi_blur", .headers_ = {}, .body_ = "img1\nimg2\nimg3\nimg4\n"}; |
| 219 | |
| 220 | // The handler for the /edge_detect requests |
| 221 | ex::sender auto snd = handle_multi_blur_request(req); |
| 222 | |
| 223 | // Pack this into a simplified flow and execute it asynchronously |
| 224 | ex::sender auto action = std::move(snd) |
| 225 | | ex::then( |
| 226 | [](http_response resp) |
| 227 | { |
| 228 | std::ostringstream oss; |
| 229 | oss << "Sending response: " << resp.status_code_ << " / " |
| 230 | << resp.body_ << "\n"; |
| 231 | std::cout << oss.str(); |
| 232 | }); |
| 233 | scope.spawn(ex::starts_on(sched, std::move(action))); |
| 234 | } |
| 235 | |
| 236 | stdexec::sync_wait(scope.on_empty()); |
| 237 | pool.request_stop(); |
| 238 | } |
nothing calls this directly
no test coverage detected