| 227 | } |
| 228 | |
| 229 | djinni::Future<std::string> TestHelpers::check_async_composition(const std::shared_ptr<AsyncInterface> & i) { |
| 230 | djinni::Promise<std::string> p1; |
| 231 | djinni::Promise<std::string> p2; |
| 232 | auto f1 = p1.getFuture(); |
| 233 | auto f2 = p2.getFuture(); |
| 234 | |
| 235 | auto str2num = [] (djinni::Future<std::string> s) { |
| 236 | return std::stoi(s.get()); |
| 237 | }; |
| 238 | |
| 239 | auto f3 = f1.then(str2num); |
| 240 | auto f4 = f2.then(str2num); |
| 241 | |
| 242 | std::vector<djinni::Future<std::string>> futures; |
| 243 | futures.push_back(i->future_roundtrip(std::move(f3))); |
| 244 | futures.push_back(i->future_roundtrip(std::move(f4))); |
| 245 | |
| 246 | p1.setValue("36"); |
| 247 | p2.setValue("36"); |
| 248 | |
| 249 | #ifdef DJINNI_FUTURE_HAS_COROUTINE_SUPPORT |
| 250 | co_await djinni::whenAll(futures); |
| 251 | co_return std::string("42"); |
| 252 | #else |
| 253 | return djinni::whenAll(futures).then([] (auto f) { |
| 254 | return std::string("42"); |
| 255 | }); |
| 256 | #endif |
| 257 | } |
| 258 | |
| 259 | ::djinni::Future<void> TestHelpers::void_async_method(djinni::Future<void> f) { |
| 260 | #ifdef DJINNI_FUTURE_HAS_COROUTINE_SUPPORT |