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
/
kernel
/
activity
/
MutexImpl.hpp
diff --git
a/src/kernel/activity/MutexImpl.hpp
b/src/kernel/activity/MutexImpl.hpp
index 3abf068229d3d039aa6040c2b9db94ae72d4a2f1..fa291d3bb4cb709153699d950782d6dd5ad6beb4 100644
(file)
--- a/
src/kernel/activity/MutexImpl.hpp
+++ b/
src/kernel/activity/MutexImpl.hpp
@@
-1,10
+1,10
@@
-/* Copyright (c) 2012-20
19
. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2012-20
21
. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
-#ifndef SIM
IX_MUTEXIMPL
_HPP
-#define SIM
IX_MUTEXIMPL
_HPP
+#ifndef SIM
GRID_KERNEL_ACTIVITY_MUTEX
_HPP
+#define SIM
GRID_KERNEL_ACTIVITY_MUTEX
_HPP
#include "simgrid/s4u/ConditionVariable.hpp"
#include "src/kernel/actor/ActorImpl.hpp"
#include "simgrid/s4u/ConditionVariable.hpp"
#include "src/kernel/actor/ActorImpl.hpp"
@@
-18,6
+18,9
@@
class XBT_PUBLIC MutexImpl {
std::atomic_int_fast32_t refcount_{1};
s4u::Mutex piface_;
bool locked_ = false;
std::atomic_int_fast32_t refcount_{1};
s4u::Mutex piface_;
bool locked_ = false;
+ actor::ActorImpl* owner_ = nullptr;
+ // List of sleeping actors:
+ actor::SynchroList sleeping_;
public:
MutexImpl() : piface_(this) {}
public:
MutexImpl() : piface_(this) {}
@@
-27,14
+30,13
@@
public:
void lock(actor::ActorImpl* issuer);
bool try_lock(actor::ActorImpl* issuer);
void unlock(actor::ActorImpl* issuer);
void lock(actor::ActorImpl* issuer);
bool try_lock(actor::ActorImpl* issuer);
void unlock(actor::ActorImpl* issuer);
- bool is_locked() { return locked_; }
+ bool is_locked()
const
{ return locked_; }
MutexImpl* ref();
void unref();
MutexImpl* ref();
void unref();
- actor::ActorImpl* owner_ = nullptr;
- // List of sleeping actors:
- actor::SynchroList sleeping_;
+ void remove_sleeping_actor(actor::ActorImpl& actor) { xbt::intrusive_erase(sleeping_, actor); }
+ actor::ActorImpl* get_owner() const { return owner_; }
// boost::intrusive_ptr<Mutex> support:
friend void intrusive_ptr_add_ref(MutexImpl* mutex)
// boost::intrusive_ptr<Mutex> support:
friend void intrusive_ptr_add_ref(MutexImpl* mutex)
@@
-51,7
+53,7
@@
public:
s4u::Mutex& mutex() { return piface_; }
};
s4u::Mutex& mutex() { return piface_; }
};
-}
-}
-}
-#endif
/* SIMIX_MUTEXIMPL_HPP */
+}
// namespace activity
+}
// namespace kernel
+}
// namespace simgrid
+#endif