/* 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. */
#include "simgrid/s4u/Mutex.hpp"
#include "src/kernel/activity/ActivityImpl.hpp"
#include "src/kernel/actor/ActorImpl.hpp"
#include "simgrid/s4u/Mutex.hpp"
#include "src/kernel/activity/ActivityImpl.hpp"
#include "src/kernel/actor/ActorImpl.hpp"
* of a set if some transitions may become disabled in between, while you don't have to reconsider them if you can reuse
* your previous computations).
*/
* of a set if some transitions may become disabled in between, while you don't have to reconsider them if you can reuse
* your previous computations).
*/
public:
MutexAcquisitionImpl(actor::ActorImpl* issuer, MutexImpl* mutex) : issuer_(issuer), mutex_(mutex) {}
MutexImplPtr get_mutex() { return mutex_; }
actor::ActorImpl* get_issuer() { return issuer_; }
public:
MutexAcquisitionImpl(actor::ActorImpl* issuer, MutexImpl* mutex) : issuer_(issuer), mutex_(mutex) {}
MutexImplPtr get_mutex() { return mutex_; }
actor::ActorImpl* get_issuer() { return issuer_; }
bool test(actor::ActorImpl* issuer = nullptr) override;
void wait_for(actor::ActorImpl* issuer, double timeout) override;
bool test(actor::ActorImpl* issuer = nullptr) override;
void wait_for(actor::ActorImpl* issuer, double timeout) override;
- // List of sleeping actors:
- std::deque<MutexAcquisitionImplPtr> sleeping_;
+ std::deque<MutexAcquisitionImplPtr> ongoing_acquisitions_;
+ static unsigned next_id_;
+ unsigned id_ = next_id_++;
+ bool is_recursive_ = false;
+ int recursive_depth = 0;
MutexImpl(MutexImpl const&) = delete;
MutexImpl& operator=(MutexImpl const&) = delete;
MutexAcquisitionImplPtr lock_async(actor::ActorImpl* issuer);
bool try_lock(actor::ActorImpl* issuer);
void unlock(actor::ActorImpl* issuer);
MutexImpl(MutexImpl const&) = delete;
MutexImpl& operator=(MutexImpl const&) = delete;
MutexAcquisitionImplPtr lock_async(actor::ActorImpl* issuer);
bool try_lock(actor::ActorImpl* issuer);
void unlock(actor::ActorImpl* issuer);
- if (mutex->refcount_.fetch_sub(1) == 1)
+ if (mutex->refcount_.fetch_sub(1) == 1) {
+ xbt_assert(mutex->ongoing_acquisitions_.empty(), "The destroyed mutex still had ongoing acquisitions");
+ xbt_assert(mutex->owner_ == nullptr, "The destroyed mutex is still owned by %s", mutex->owner_->get_cname());