} else {
xbt_die("Cannot start a communication before specifying whether we are the sender or the receiver");
}
- while (refcount_ > 1) { // Pass all the refcounts we had to the underlying pimpl since we are delegating the
- // refcounting to it afterward
- refcount_--;
- pimpl_->ref();
- }
state_ = started;
}
void Comm::wait() {
void Comm::cancel()
{
- simgrid::kernel::activity::Comm* commPimpl = static_cast<simgrid::kernel::activity::Comm*>(pimpl_);
+ simgrid::kernel::activity::CommImpl* commPimpl = static_cast<simgrid::kernel::activity::CommImpl*>(pimpl_);
commPimpl->cancel();
}
bool Comm::test() {
void intrusive_ptr_release(simgrid::s4u::Comm* c)
{
- if (c->pimpl_ != nullptr) {
- if (c->pimpl_->unref()) {
- c->pimpl_ = nullptr;
- delete c;
- }
- } else if (c->refcount_.fetch_sub(1, std::memory_order_release) == 1) {
+ if (c->refcount_.fetch_sub(1, std::memory_order_release) == 1) {
std::atomic_thread_fence(std::memory_order_acquire);
delete c;
}
}
void intrusive_ptr_add_ref(simgrid::s4u::Comm* c)
{
- if (c->pimpl_ != nullptr) {
- c->pimpl_->ref();
- } else {
- c->refcount_.fetch_add(1, std::memory_order_relaxed);
- }
+ c->refcount_.fetch_add(1, std::memory_order_relaxed);
}
}
} // namespaces