Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions include/async/post-ack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,15 @@ struct post_ack_agent {

auto n = nd->acks_left.fetch_sub(1, std::memory_order_acq_rel);
assert(n >= 1);
if(n == 1)
if(n == 1) {
mech_->queue_.erase(mech_->queue_.iterator_to(nd));

// Run the completion handler without locks.
lock.unlock();
nd->complete();
// Run the completion handler without locks.
lock.unlock();
nd->complete();
}else{
lock.unlock();
}

++poll_seq_;
if(retire_seq == poll_seq_) // Avoid re-locking.
Expand All @@ -305,7 +308,7 @@ struct post_ack_agent {
void start() {
assert(agnt_->mech_);

auto seq = agnt_->poll_seq_++;
auto seq = agnt_->poll_seq_;

{
frg::unique_lock lock(agnt_->mech_->mutex_);
Expand All @@ -330,13 +333,17 @@ struct post_ack_agent {
}
}

if(nd)
++agnt_->poll_seq_;
execution::set_value(receiver_, post_ack_handle<T>{agnt_->mech_, nd});
}

private:
void complete() override {
if(cobs_.try_reset())
if(cobs_.try_reset()) {
++agnt_->poll_seq_;
execution::set_value(receiver_, post_ack_handle<T>{agnt_->mech_, nd});
}
}

void complete_cancel() {
Expand All @@ -350,10 +357,12 @@ struct post_ack_agent {
}
}

if(nd)
if(nd) {
++agnt_->poll_seq_;
execution::set_value(receiver_, post_ack_handle<T>{agnt_->mech_, nd});
else
}else{
execution::set_value(receiver_, post_ack_handle<T>{});
}
}

post_ack_agent *agnt_;
Expand Down
Loading