-
Notifications
You must be signed in to change notification settings - Fork 18
Stack overflow threadid #224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ import std; | |
| #include <concepts> | ||
| #include <coroutine> | ||
| #include <exception> | ||
| #include <thread> | ||
| #include <tuple> | ||
| #include <type_traits> | ||
| #include <utility> | ||
|
|
@@ -53,13 +54,15 @@ class sender_awaitable { | |
| ::beman::execution::detail::single_sender_value_type<Sndr, ::beman::execution::env_of_t<Promise>>; | ||
| using result_type = ::std::conditional_t<::std::is_void_v<value_type>, unit, value_type>; | ||
| using variant_type = ::std::variant<::std::monostate, result_type, ::std::exception_ptr>; | ||
| using data_type = ::std::tuple<variant_type, ::std::atomic<bool>, ::std::coroutine_handle<Promise>>; | ||
| using data_type = ::std::tuple<variant_type, ::std::atomic<::std::thread::id>, ::std::coroutine_handle<Promise>>; | ||
|
|
||
|
Comment on lines
56
to
58
|
||
| struct awaitable_receiver { | ||
| using receiver_concept = ::beman::execution::receiver_t; | ||
|
|
||
| void resume() { | ||
| if (::std::get<1>(*result_ptr_).exchange(true, std::memory_order_acq_rel)) { | ||
| std::thread::id id(::std::this_thread::get_id()); | ||
| if (not ::std::get<1>(*result_ptr_) | ||
| .compare_exchange_strong(id, ::std::thread::id{}, std::memory_order_acq_rel)) { | ||
| ::std::get<2>(*result_ptr_).resume(); | ||
| } | ||
|
Comment on lines
62
to
67
|
||
| } | ||
|
|
@@ -82,7 +85,9 @@ class sender_awaitable { | |
| } | ||
|
|
||
| void set_stopped() && noexcept { | ||
| if (::std::get<1>(*result_ptr_).exchange(true, ::std::memory_order_acq_rel)) { | ||
| std::thread::id id(::std::this_thread::get_id()); | ||
| if (not ::std::get<1>(*result_ptr_) | ||
| .compare_exchange_strong(id, ::std::thread::id{}, ::std::memory_order_acq_rel)) { | ||
| static_cast<::std::coroutine_handle<>>(::std::get<2>(*result_ptr_).promise().unhandled_stopped()) | ||
| .resume(); | ||
| } | ||
|
|
@@ -102,14 +107,16 @@ class sender_awaitable { | |
|
|
||
| public: | ||
| sender_awaitable(Sndr&& sndr, Promise& p) | ||
| : result{::std::monostate{}, false, ::std::coroutine_handle<Promise>::from_promise(p)}, | ||
| : result{::std::monostate{}, ::std::this_thread::get_id(), ::std::coroutine_handle<Promise>::from_promise(p)}, | ||
| state{::beman::execution::connect(::std::forward<Sndr>(sndr), | ||
| sender_awaitable::awaitable_receiver{::std::addressof(result)})} {} | ||
|
|
||
| static constexpr bool await_ready() noexcept { return false; } | ||
| ::std::coroutine_handle<> await_suspend(::std::coroutine_handle<Promise> handle) noexcept { | ||
| ::beman::execution::start(state); | ||
| if (::std::get<1>(this->result).exchange(true, std::memory_order_acq_rel)) { | ||
| ::std::thread::id id(::std::this_thread::get_id()); | ||
| if (not ::std::get<1>(this->result) | ||
| .compare_exchange_strong(id, ::std::thread::id{}, ::std::memory_order_acq_rel)) { | ||
| if (::std::holds_alternative<::std::monostate>(::std::get<0>(this->result))) { | ||
| return ::std::get<2>(this->result).promise().unhandled_stopped(); | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
export CXX_FLAGS=-stdlib=$(CXXLIB)overwrites the existingCXX_FLAGS(e.g., drops-g) and is later overwritten by the SANITIZER-specificCXX_FLAGS = ...assignments, so the stdlib selection can be lost. Also,-stdlib=...is a clang-specific flag; if theelsebranch selectsg++-15, passing-stdlib=libstdc++viaCMAKE_CXX_FLAGSwill likely fail. Consider keeping stdlib selection in a separate variable and appending it toCXX_FLAGS, and only adding-stdlib=...when using clang/libc++.