NVIDIA/stdexec

inplace_stop_token::request_stop() returns an inverted value

Opened this issue · 0 comments

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_();
}