X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/78cfd86352a4b7097c255e40e8eb98619d515926..ea74f5d95928a521a588737e81f1de94eef25d19:/src/kernel/activity/MutexImpl.hpp diff --git a/src/kernel/activity/MutexImpl.hpp b/src/kernel/activity/MutexImpl.hpp index f372ea76d5..a88b74ed2d 100644 --- a/src/kernel/activity/MutexImpl.hpp +++ b/src/kernel/activity/MutexImpl.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2019. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2012-2022. 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. */ @@ -6,7 +6,7 @@ #ifndef SIMGRID_KERNEL_ACTIVITY_MUTEX_HPP #define SIMGRID_KERNEL_ACTIVITY_MUTEX_HPP -#include "simgrid/s4u/ConditionVariable.hpp" +#include "simgrid/s4u/Mutex.hpp" #include "src/kernel/actor/ActorImpl.hpp" #include @@ -18,6 +18,9 @@ class XBT_PUBLIC MutexImpl { 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) {} @@ -27,14 +30,13 @@ public: 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(); - 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 support: friend void intrusive_ptr_add_ref(MutexImpl* mutex)