Skip to content

Commit a322a1c

Browse files
author
Conor
committed
stash exception from stack allocation
1 parent 0f3c957 commit a322a1c

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/core/promise.cxx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ struct mixin_frame {
377377

378378
template <category Cat, typename R, typename Fn, typename... Args>
379379
[[nodiscard]]
380-
static constexpr auto transform(pkg<R, Fn, Args...> &&pkg) noexcept -> frame_type<Context> * {
380+
constexpr auto transform(this auto &self, pkg<R, Fn, Args...> &&pkg) noexcept -> frame_type<Context> * {
381381
LF_TRY {
382382
task child = std::move(pkg.args).apply(std::move(pkg.fn));
383383

@@ -395,21 +395,22 @@ struct mixin_frame {
395395

396396
return &child.promise->frame;
397397
} LF_CATCH_ALL {
398-
// TODO: stash exception
399-
return nullptr;
398+
return stash_current_exception(&self.frame), nullptr;
400399
}
401400
}
402401

402+
using enum category;
403+
403404
template <typename R, typename Fn, typename... Args>
404-
constexpr static auto
405-
await_transform(call_pkg<R, Fn, Args...> &&pkg) noexcept -> awaitable<category::call, Context> {
406-
return {.child = transform<category::call>(std::move(pkg))};
405+
constexpr auto
406+
await_transform(this auto &self, call_pkg<R, Fn, Args...> &&pkg) noexcept -> awaitable<call, Context> {
407+
return {.child = self.template transform<call>(std::move(pkg))};
407408
}
408409

409410
template <typename R, typename Fn, typename... Args>
410-
constexpr static auto
411-
await_transform(fork_pkg<R, Fn, Args...> &&pkg) noexcept -> awaitable<category::fork, Context> {
412-
return {.child = transform<category::fork>(std::move(pkg))};
411+
constexpr auto
412+
await_transform(this auto self, fork_pkg<R, Fn, Args...> &&pkg) noexcept -> awaitable<fork, Context> {
413+
return {.child = self.template transform<fork>(std::move(pkg))};
413414
}
414415

415416
constexpr auto await_transform(this auto &self, join_type) noexcept -> join_awaitable<Context> {

0 commit comments

Comments
 (0)