- XBT_IN("(%p)", cond);
- XBT_DEBUG("Destroy condition %p", cond);
- if (cond != nullptr) {
- intrusive_ptr_release(cond);
+ if (cond->refcount_.fetch_sub(1, std::memory_order_release) == 1) {
+ std::atomic_thread_fence(std::memory_order_acquire);
+ xbt_assert(cond->sleeping.empty(), "Cannot destroy conditional since someone is still using it");
+ delete cond;