Skip to content

Commit 8194a89

Browse files
author
Conor
committed
!TMP faster
1 parent ee7c24b commit 8194a89

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/core/promise.cxx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,18 @@ struct promise_deleter {
3030
}
3131
};
3232

33+
// template <typename T>
34+
// using unique_promise = std::unique_ptr<T, promise_deleter>;
3335
template <typename T>
34-
using unique_promise = std::unique_ptr<T, promise_deleter>;
36+
struct unique_promise {
37+
T *a;
38+
39+
constexpr auto operator*() noexcept -> T & { return *a; }
40+
constexpr auto operator->() noexcept -> T * { return a; }
41+
constexpr operator bool() const noexcept { return a != nullptr; }
42+
constexpr auto release() noexcept -> T * { return a; }
43+
constexpr auto operator==(std::nullptr_t) const noexcept -> bool { return a == nullptr; }
44+
};
3545

3646
/**
3747
* @brief The return type for libfork's async functions/coroutines.
@@ -63,7 +73,7 @@ constexpr auto final_suspend(frame_type *frame) -> std::coroutine_handle<> {
6373

6474
{
6575
// Destroy the child frame
66-
unique_promise<frame_type> _{frame};
76+
promise_deleter::operator()(frame);
6777
}
6878

6979
if (parent_frame != nullptr) {
@@ -136,7 +146,7 @@ struct promise_type<void, StackPolicy> : StackPolicy, mixin_frame {
136146

137147
frame_type frame;
138148

139-
constexpr auto get_return_object() -> task<void, StackPolicy> { return {{this, {}}}; }
149+
constexpr auto get_return_object() -> task<void, StackPolicy> { return {{this}}; }
140150

141151
constexpr static void return_void() {}
142152
};

0 commit comments

Comments
 (0)