MCPcopy Create free account
hub / github.com/Snapchat/djinni / check_async_composition

Method check_async_composition

test-suite/handwritten-src/cpp/test_helpers.cpp:229–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

227}
228
229djinni::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

Callers

nothing calls this directly

Calls 6

whenAllFunction · 0.85
getMethod · 0.65
getFutureMethod · 0.45
thenMethod · 0.45
future_roundtripMethod · 0.45
setValueMethod · 0.45

Tested by

no test coverage detected