| 158 | } |
| 159 | |
| 160 | auto handle_multi_blur_request(http_request const & req) -> ex::sender auto |
| 161 | { |
| 162 | return |
| 163 | // extract the input images from the request |
| 164 | ex::just(req) |
| 165 | | ex::then(extract_images) |
| 166 | // process images in parallel with bulk. |
| 167 | // use let_value to access the image count before calling bulk. |
| 168 | | ex::let_value( |
| 169 | [](std::vector<image> imgs) |
| 170 | { |
| 171 | // get the image count |
| 172 | size_t img_count = imgs.size(); |
| 173 | // return a sender that bulk-processes the image in parallel |
| 174 | return ex::just(std::move(imgs)) |
| 175 | | ex::bulk(ex::par, |
| 176 | img_count, |
| 177 | [](size_t i, std::vector<image>& imgs) { imgs[i] = apply_blur(imgs[i]); }); |
| 178 | }) |
| 179 | // transform the resulting 3 images into an HTTP response |
| 180 | | ex::then(imgvec_to_response) |
| 181 | // done; error and cancellation handling is performed outside |
| 182 | ; |
| 183 | } |
| 184 | |
| 185 | auto main() -> int |
| 186 | { |
no test coverage detected