From 59716de74dad700cb3f12204524a63b895a39c27 Mon Sep 17 00:00:00 2001 From: Martin Quinson Date: Thu, 24 Feb 2022 23:19:37 +0100 Subject: [PATCH] kill some remains of the pre-C++ era Back then, humans were supposed to manage the refcount manually. --- src/kernel/activity/MutexImpl.cpp | 12 ------------ src/kernel/activity/MutexImpl.hpp | 3 --- src/kernel/activity/SemaphoreImpl.cpp | 13 ------------- src/kernel/activity/SemaphoreImpl.hpp | 3 --- src/s4u/s4u_Mutex.cpp | 6 ++---- src/s4u/s4u_Semaphore.cpp | 6 ++---- 6 files changed, 4 insertions(+), 39 deletions(-) diff --git a/src/kernel/activity/MutexImpl.cpp b/src/kernel/activity/MutexImpl.cpp index f1e089fbc5..bfce33a84e 100644 --- a/src/kernel/activity/MutexImpl.cpp +++ b/src/kernel/activity/MutexImpl.cpp @@ -115,18 +115,6 @@ void MutexImpl::unlock(actor::ActorImpl* issuer) } XBT_OUT(); } -/** Increase the refcount for this mutex */ -MutexImpl* MutexImpl::ref() -{ - intrusive_ptr_add_ref(this); - return this; -} - -/** Decrease the refcount for this mutex */ -void MutexImpl::unref() -{ - intrusive_ptr_release(this); -} } // namespace activity } // namespace kernel diff --git a/src/kernel/activity/MutexImpl.hpp b/src/kernel/activity/MutexImpl.hpp index 5ab4b5d21d..347880d057 100644 --- a/src/kernel/activity/MutexImpl.hpp +++ b/src/kernel/activity/MutexImpl.hpp @@ -83,9 +83,6 @@ public: void unlock(actor::ActorImpl* issuer); unsigned get_id() const { return id_; } - MutexImpl* ref(); - void unref(); - actor::ActorImpl* get_owner() const { return owner_; } // boost::intrusive_ptr support: diff --git a/src/kernel/activity/SemaphoreImpl.cpp b/src/kernel/activity/SemaphoreImpl.cpp index 85c1edf972..021ef85150 100644 --- a/src/kernel/activity/SemaphoreImpl.cpp +++ b/src/kernel/activity/SemaphoreImpl.cpp @@ -48,19 +48,6 @@ void SemaphoreImpl::release() } } -/** Increase the refcount for this semaphore */ -SemaphoreImpl* SemaphoreImpl::ref() -{ - intrusive_ptr_add_ref(this); - return this; -} - -/** Decrease the refcount for this mutex */ -void SemaphoreImpl::unref() -{ - intrusive_ptr_release(this); -} - } // namespace activity } // namespace kernel } // namespace simgrid diff --git a/src/kernel/activity/SemaphoreImpl.hpp b/src/kernel/activity/SemaphoreImpl.hpp index 47a6f71f1f..3704fc4e82 100644 --- a/src/kernel/activity/SemaphoreImpl.hpp +++ b/src/kernel/activity/SemaphoreImpl.hpp @@ -36,9 +36,6 @@ public: unsigned int get_capacity() const { return value_; } bool is_used() const { return not sleeping_.empty(); } - SemaphoreImpl* ref(); - void unref(); - friend void intrusive_ptr_add_ref(SemaphoreImpl* sem) { XBT_ATTRIB_UNUSED auto previous = sem->refcount_.fetch_add(1); diff --git a/src/s4u/s4u_Mutex.cpp b/src/s4u/s4u_Mutex.cpp index e429dac015..3fca4c43f1 100644 --- a/src/s4u/s4u_Mutex.cpp +++ b/src/s4u/s4u_Mutex.cpp @@ -64,13 +64,11 @@ MutexPtr Mutex::create() /* refcounting of the intrusive_ptr is delegated to the implementation object */ void intrusive_ptr_add_ref(const Mutex* mutex) { - xbt_assert(mutex); - mutex->pimpl_->ref(); + intrusive_ptr_add_ref(mutex->pimpl_); } void intrusive_ptr_release(const Mutex* mutex) { - xbt_assert(mutex); - mutex->pimpl_->unref(); + intrusive_ptr_release(mutex->pimpl_); } } // namespace s4u diff --git a/src/s4u/s4u_Semaphore.cpp b/src/s4u/s4u_Semaphore.cpp index 78a6dcf6da..05a203c9a7 100644 --- a/src/s4u/s4u_Semaphore.cpp +++ b/src/s4u/s4u_Semaphore.cpp @@ -51,14 +51,12 @@ bool Semaphore::would_block() const /* refcounting of the intrusive_ptr is delegated to the implementation object */ void intrusive_ptr_add_ref(const Semaphore* sem) { - xbt_assert(sem); - sem->pimpl_->ref(); + intrusive_ptr_add_ref(sem->pimpl_); } void intrusive_ptr_release(const Semaphore* sem) { - xbt_assert(sem); - sem->pimpl_->unref(); + intrusive_ptr_release(sem->pimpl_); } } // namespace s4u -- 2.20.1