diff --git a/headers/private/shared/Referenceable.h b/headers/private/shared/Referenceable.h index 264eaea6ea..f020d7e163 100644 --- a/headers/private/shared/Referenceable.h +++ b/headers/private/shared/Referenceable.h @@ -17,7 +17,7 @@ public: BReferenceable(); virtual ~BReferenceable(); - void AcquireReference(); + int32 AcquireReference(); bool ReleaseReference(); // returns true after last diff --git a/src/kits/support/Referenceable.cpp b/src/kits/support/Referenceable.cpp index 3df724635e..39906255ae 100644 --- a/src/kits/support/Referenceable.cpp +++ b/src/kits/support/Referenceable.cpp @@ -28,13 +28,16 @@ BReferenceable::~BReferenceable() } -void +int32 BReferenceable::AcquireReference() { - if (atomic_add(&fReferenceCount, 1) == 0) + int32 previousReferenceCount = atomic_add(&fReferenceCount, 1); + if (previousReferenceCount == 0) FirstReferenceAcquired(); TRACE("%p: acquire %ld\n", this, fReferenceCount); + + return previousReferenceCount; }