A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Modernize simcall mutex_lock.
[simgrid.git]
/
src
/
s4u
/
s4u_Mutex.cpp
diff --git
a/src/s4u/s4u_Mutex.cpp
b/src/s4u/s4u_Mutex.cpp
index
6034aeb
..
8975cb7
100644
(file)
--- a/
src/s4u/s4u_Mutex.cpp
+++ b/
src/s4u/s4u_Mutex.cpp
@@
-7,6
+7,7
@@
#include "simgrid/mutex.h"
#include "simgrid/s4u/Mutex.hpp"
#include "src/kernel/activity/MutexImpl.hpp"
#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 {
namespace simgrid {
namespace s4u {
@@
-20,7
+21,9
@@
Mutex::~Mutex()
/** @brief Blocks the calling actor until the mutex can be obtained */
void Mutex::lock()
{
/** @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)
}
/** @brief Release the ownership of the mutex, unleashing a blocked actor (if any)
@@
-29,13
+32,18
@@
void Mutex::lock()
*/
void Mutex::unlock()
{
*/
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()
{
}
/** @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
}
/** @brief Create a new mutex