Skip to content
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

inplace_stop_token::request_stop() returns an inverted value #1419

Open
lewissbaker opened this issue Oct 7, 2024 · 0 comments
Open

inplace_stop_token::request_stop() returns an inverted value #1419

lewissbaker opened this issue Oct 7, 2024 · 0 comments

Comments

@lewissbaker
Copy link
Contributor

The specification for a stop-source requires that the request_stop() method returns true if a stop-request was made and false if a stop-request could not be made (e.g. because a stop-request had already been made).

However, the current implementation of stdexec::inplace_stop_source::request_stop() as the result inverted.
It returns false if a stop-request was made and true if a stop-request was not made.

See:

inline auto inplace_stop_source::request_stop() noexcept -> bool {
if (!__try_lock_unless_stop_requested_(true))
return true;
__notifying_thread_ = std::this_thread::get_id();
// We are responsible for executing callbacks.
while (__callbacks_ != nullptr) {
auto* __callbk = __callbacks_;
__callbk->__prev_ptr_ = nullptr;
__callbacks_ = __callbk->__next_;
if (__callbacks_ != nullptr)
__callbacks_->__prev_ptr_ = &__callbacks_;
__state_.store(__stop_requested_flag_, std::memory_order_release);
bool __removed_during_callback = false;
__callbk->__removed_during_callback_ = &__removed_during_callback;
__callbk->__execute();
if (!__removed_during_callback) {
__callbk->__removed_during_callback_ = nullptr;
__callbk->__callback_completed_.store(true, std::memory_order_release);
}
__lock_();
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant