X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/956cb23848021301bcb4c20fd31675f65e4348e5..a5a8281d1b8c42bbdb10d492d7251b35759ea32d:/src/kernel/activity/MutexImpl.hpp diff --git a/src/kernel/activity/MutexImpl.hpp b/src/kernel/activity/MutexImpl.hpp index 8937ee2149..27a47c137d 100644 --- a/src/kernel/activity/MutexImpl.hpp +++ b/src/kernel/activity/MutexImpl.hpp @@ -1,4 +1,4 @@ -/* Copyright (c) 2012-2017. The SimGrid Team. All rights reserved. */ +/* Copyright (c) 2012-2019. 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. */ @@ -7,27 +7,29 @@ #define SIMIX_MUTEXIMPL_HPP #include "simgrid/s4u/ConditionVariable.hpp" -#include "src/simix/ActorImpl.hpp" +#include "src/kernel/actor/ActorImpl.hpp" #include namespace simgrid { -namespace simix { +namespace kernel { +namespace activity { -class XBT_PUBLIC() MutexImpl { +class XBT_PUBLIC MutexImpl { public: - MutexImpl(); - ~MutexImpl(); + MutexImpl() : piface_(this) {} MutexImpl(MutexImpl const&) = delete; MutexImpl& operator=(MutexImpl const&) = delete; - void lock(smx_actor_t issuer); - bool try_lock(smx_actor_t issuer); - void unlock(smx_actor_t issuer); + void lock(actor::ActorImpl* issuer); + bool try_lock(actor::ActorImpl* issuer); + void unlock(actor::ActorImpl* issuer); - bool locked = false; - smx_actor_t owner = nullptr; - // List of sleeping processes: - simgrid::simix::SynchroList sleeping; + MutexImpl* ref(); + void unref(); + bool locked_ = false; + actor::ActorImpl* owner_ = nullptr; + // List of sleeping actors: + actor::SynchroList sleeping_; // boost::intrusive_ptr support: friend void intrusive_ptr_add_ref(MutexImpl* mutex) @@ -35,18 +37,20 @@ public: XBT_ATTRIB_UNUSED auto previous = mutex->refcount_.fetch_add(1); xbt_assert(previous != 0); } + friend void intrusive_ptr_release(MutexImpl* mutex) { if (mutex->refcount_.fetch_sub(1) == 1) delete mutex; } - simgrid::s4u::Mutex& mutex() { return mutex_; } + s4u::Mutex& mutex() { return piface_; } private: std::atomic_int_fast32_t refcount_{1}; - simgrid::s4u::Mutex mutex_; + s4u::Mutex piface_; }; } } +} #endif /* SIMIX_MUTEXIMPL_HPP */