| 138 | } |
| 139 | |
| 140 | auto handle_edge_detection_request(http_request const & req) -> ex::sender auto |
| 141 | { |
| 142 | // extract the input image from the request |
| 143 | ex::sender auto in_img_sender = ex::just(req) | ex::then(extract_image); |
| 144 | |
| 145 | // Prepare for using multiple parallel flows on the same input sender |
| 146 | // ex::sender auto multi_shot_img = exec::split(in_img_sender); |
| 147 | auto& multi_shot_img = in_img_sender; |
| 148 | |
| 149 | // Apply the three methods of edge detection on the same input image, in parallel. |
| 150 | // Then, join the results and generate the HTTP response |
| 151 | return ex::when_all(multi_shot_img | ex::then(apply_canny), |
| 152 | multi_shot_img | ex::then(apply_sobel), |
| 153 | multi_shot_img | ex::then(apply_prewitt)) |
| 154 | | |
| 155 | // transform the resulting 3 images into an HTTP response |
| 156 | ex::then(img3_to_response); |
| 157 | // error and cancellation handling is performed outside |
| 158 | } |
| 159 | |
| 160 | auto handle_multi_blur_request(http_request const & req) -> ex::sender auto |
| 161 | { |