From bf60220bccb0e08cc14bd1ce5600b4f1aa993e66 Mon Sep 17 00:00:00 2001 From: Kwanho Lee Date: Wed, 24 Jul 2024 08:40:09 -0700 Subject: [PATCH] address comments --- support-lib/cpp/SharedFuture.hpp | 11 ++--------- .../handwritten-src/objc/tests/DBSharedFutureTest.mm | 6 +++--- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/support-lib/cpp/SharedFuture.hpp b/support-lib/cpp/SharedFuture.hpp index d2f3abd7..97f82368 100644 --- a/support-lib/cpp/SharedFuture.hpp +++ b/support-lib/cpp/SharedFuture.hpp @@ -63,13 +63,6 @@ class SharedFuture { co_return transform(cpy); } - // Overload for T = void or `transform` takes no arugment. - template&>>> - SharedFuture>>> then(Func transform) const { - co_await SharedFuture(*this); // retain copy during coroutine suspension - co_return transform(); - } - // -- coroutine support implementation only; not intended externally -- bool await_ready() const { @@ -132,8 +125,8 @@ SharedFuture::SharedFuture(Future&& future) { } else { sharedStates->storedValue = futureResult.get(); } - } catch (const std::exception& e) { - sharedStates->storedValue = make_unexpected(std::make_exception_ptr(e)); + } catch (...) { + sharedStates->storedValue = make_unexpected(std::current_exception()); } return std::move(sharedStates->coroutineHandles); }(); diff --git a/test-suite/handwritten-src/objc/tests/DBSharedFutureTest.mm b/test-suite/handwritten-src/objc/tests/DBSharedFutureTest.mm index d02c9f08..fb8c3f1a 100644 --- a/test-suite/handwritten-src/objc/tests/DBSharedFutureTest.mm +++ b/test-suite/handwritten-src/objc/tests/DBSharedFutureTest.mm @@ -55,10 +55,10 @@ - (void)testThen XCTAssertEqual(futureInt.get(), 42); - auto voidFuture = transformedString.then([]() {}); + auto voidFuture = transformedString.then([](auto) {}); voidFuture.wait(); - auto intFuture2 = voidFuture.then([]() { return 43; }); + auto intFuture2 = voidFuture.then([](auto) { return 43; }); XCTAssertEqual(intFuture2.get(), 43); } @@ -72,7 +72,7 @@ - (void)testException XCTAssertThrows(futureInt.get()); - auto thenResult = futureInt.then([]() { return 43; }); + auto thenResult = futureInt.then([](const auto& resolved) { return resolved.get(); }); XCTAssertThrows(thenResult.get()); auto withExceptionHandling = futureInt.then([](const auto& resolved) {