}
XBT_OUT();
}
+/** Increase the refcount for this mutex */
+MutexImpl* MutexImpl::ref()
+{
+ intrusive_ptr_add_ref(this);
+ return this;
}
+
+/** Decrease the refcount for this mutex */
+void MutexImpl::unref()
+{
+ intrusive_ptr_release(this);
}
-}
+
+} // namespace activity
+} // namespace kernel
+} // namespace simgrid
/** Increase the refcount for this mutex */
smx_mutex_t SIMIX_mutex_ref(smx_mutex_t mutex)
bool try_lock(smx_actor_t issuer);
void unlock(smx_actor_t issuer);
+ MutexImpl* ref();
+ void unref();
bool locked = false;
smx_actor_t owner = nullptr;
// List of sleeping processes:
Mutex::~Mutex()
{
- SIMIX_mutex_unref(pimpl_);
+ if (pimpl_ != nullptr)
+ pimpl_->unref();
}
+
/** @brief Blocks the calling actor until the mutex can be obtained */
void Mutex::lock()
{
void intrusive_ptr_add_ref(Mutex* mutex)
{
xbt_assert(mutex);
- SIMIX_mutex_ref(mutex->pimpl_);
+ if (mutex->pimpl_)
+ mutex->pimpl_->ref();
}
void intrusive_ptr_release(Mutex* mutex)
{
xbt_assert(mutex);
- SIMIX_mutex_unref(mutex->pimpl_);
+ if (mutex->pimpl_)
+ mutex->pimpl_->unref();
}
+
} // namespace s4u
} // namespace simgrid