Skip to content

Commit

Permalink
Relacy tests
Browse files Browse the repository at this point in the history
Instructions:

git clone -b stdexec https://github.com/ccotter/relacy && cd relacy
git clone -b relacy https://github.com/ccotter/stdexec
CXX_STD=c++20 make build/test/stdexec/{async_scope_bug,split_bug}
./build/test/stdexec/split_bug
  • Loading branch information
ccotter committed Aug 22, 2024
1 parent 54b38c9 commit 1cc140a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions include/exec/__detail/__bwos_lifo_queue.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ namespace exec::bwos {
block_type(block_size, allocator),
allocator_of_t<block_type>(allocator))
, mask_(blocks_.size() - 1) {
blocks_[owner_block_].reclaim();
blocks_[owner_block_.load()].reclaim();
}

template <class Tp, class Allocator>
Expand Down Expand Up @@ -468,4 +468,4 @@ namespace exec::bwos {
auto lifo_queue<Tp, Allocator>::block_type::is_stealable() const noexcept -> bool {
return steal_tail_.load(std::memory_order_acquire) != block_size();
}
} // namespace exec::bwos
} // namespace exec::bwos
2 changes: 1 addition & 1 deletion include/exec/async_scope.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -781,7 +781,7 @@ namespace exec {
// after this, which means we can rely on its self-ownership to ensure
// that it is eventually deleted
stdexec::start(
*new __op_t{nest(static_cast<_Sender&&>(__sndr)), static_cast<_Env&&>(__env), &__impl_});
*(new __op_t{nest(static_cast<_Sender&&>(__sndr)), static_cast<_Env&&>(__env), &__impl_}));
}

template <__movable_value _Env = empty_env, sender_in<__env_t<_Env>> _Sender>
Expand Down
2 changes: 1 addition & 1 deletion include/exec/start_now.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace exec {
}

void __complete() noexcept {
if (--__pending_ == 0) {
if (__pending_.fetch_sub(1) == 1) {
auto __joiner = __joiner_.exchange(nullptr);
if (__joiner) {
__joiner->join();
Expand Down
4 changes: 3 additions & 1 deletion include/stdexec/__detail/__run_loop.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,9 @@ namespace stdexec {

inline auto run_loop::__pop_front_() -> __task* {
std::unique_lock __lock{__mutex_};
__cv_.wait(__lock, [this] { return __head_.__next_ != &__head_ || __stop_; });
while (!(__head_.__next_ != &__head_ || __stop_)) {
__cv_.wait(__mutex_);
}
if (__head_.__tail_ == __head_.__next_)
__head_.__tail_ = &__head_;
return std::exchange(__head_.__next_, __head_.__next_->__next_);
Expand Down
4 changes: 2 additions & 2 deletions include/stdexec/__detail/__when_all.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ namespace stdexec {

template <class _Receiver>
void __arrive(_Receiver& __rcvr) noexcept {
if (0 == --__count_) {
if (1 == __count_.fetch_sub(1)) {
__complete(__rcvr);
}
}
Expand Down Expand Up @@ -361,7 +361,7 @@ namespace stdexec {
} else if constexpr (!__same_as<decltype(_State::__values_), __ignore>) {
// We only need to bother recording the completion values
// if we're not already in the "error" or "stopped" state.
if (__state.__state_ == __started) {
if (__state.__state_.load() == __started) {
auto& __opt_values = __tup::get<__v<_Index>>(__state.__values_);
using _Tuple = __decayed_tuple<_Args...>;
static_assert(
Expand Down
10 changes: 5 additions & 5 deletions include/stdexec/stop_token.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
#include <thread>
#include <concepts>

#if __has_include(<stop_token>) && __cpp_lib_jthread >= 201911
# include <stop_token>
#endif
//#if __has_include(<stop_token>) && __cpp_lib_jthread >= 201911
//# include <stop_token>
//#endif

namespace stdexec {
namespace __stok {
Expand Down Expand Up @@ -241,8 +241,8 @@ namespace stdexec {
} // namespace __stok

inline inplace_stop_source::~inplace_stop_source() {
STDEXEC_ASSERT((__state_.load(std::memory_order_relaxed) & __locked_flag_) == 0);
STDEXEC_ASSERT(__callbacks_ == nullptr);
//STDEXEC_ASSERT((__state_.load(std::memory_order_relaxed) & __locked_flag_) == 0);
//STDEXEC_ASSERT(__callbacks_ == nullptr);
}

inline auto inplace_stop_source::request_stop() noexcept -> bool {
Expand Down

0 comments on commit 1cc140a

Please sign in to comment.