Skip to content

Commit f946380

Browse files
author
Conor
committed
finish stash
1 parent 7990d91 commit f946380

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/core/promise.cxx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,10 @@ template <category Cat, worker_context Context>
166166
struct awaitable : std::suspend_always {
167167

168168
using enum category;
169+
using except_type = frame_type<Context>::except_type;
169170

170171
frame_type<Context> *child;
171172

172-
// TODO: optional cancellation token
173-
174173
template <typename T>
175174
LF_NO_INLINE constexpr void
176175
stash_exception(this awaitable self, coro<promise_type<T, Context>> parent) noexcept {
@@ -179,10 +178,16 @@ struct awaitable : std::suspend_always {
179178

180179
frame_type<Context> &frame = parent.promise().frame;
181180

182-
// No synchronisation is done via exception_bit, hence we can use relaxed atomics and
183-
// rely on the usual fork/join synchronisation to ensure memory ordering.
181+
// No synchronisation is done via exception_bit, hence we can use relaxed atomics
182+
// and rely on the usual fork/join synchronisation to ensure memory ordering.
184183
if (frame.atomic_except().exchange(1, std::memory_order_relaxed) == 0) {
184+
frame.except = new except_type{
185+
.stashed = frame.parent,
186+
.exception = std::current_exception(),
187+
};
185188
}
189+
190+
// Else, the exception is dropped.
186191
}
187192

188193
template <typename T>

0 commit comments

Comments
 (0)