#include "simgrid/mutex.h"
#include "simgrid/s4u/Mutex.hpp"
#include "src/kernel/activity/MutexImpl.hpp"
+#include "src/mc/checker/SimcallObserver.hpp"
namespace simgrid {
namespace s4u {
/** @brief Blocks the calling actor until the mutex can be obtained */
void Mutex::lock()
{
- simcall_mutex_lock(pimpl_);
+ kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
+ mc::MutexLockSimcall observer{issuer, pimpl_};
+ kernel::actor::simcall_blocking<void>([&observer] { observer.get_mutex()->lock(observer.get_issuer()); }, &observer);
}
/** @brief Release the ownership of the mutex, unleashing a blocked actor (if any)
*/
void Mutex::unlock()
{
- simcall_mutex_unlock(pimpl_);
+ kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
+ mc::MutexUnlockSimcall observer{issuer};
+ kernel::actor::simcall([this, issuer] { this->pimpl_->unlock(issuer); }, &observer);
}
/** @brief Acquire the mutex if it's free, and return false (without blocking) if not */
bool Mutex::try_lock()
{
- return simcall_mutex_trylock(pimpl_);
+ kernel::actor::ActorImpl* issuer = kernel::actor::ActorImpl::self();
+ mc::MutexTrylockSimcall observer{issuer, pimpl_};
+ return kernel::actor::simcall([&observer] { return observer.get_mutex()->try_lock(observer.get_issuer()); },
+ &observer);
}
/** @brief Create a new mutex