AcquireReference() now returns the previous ref count.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42079 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent 2011-06-10 01:55:12 +00:00
parent ad12a198d7
commit a99d0dd7b7
2 changed files with 6 additions and 3 deletions

View File

@ -17,7 +17,7 @@ public:
BReferenceable();
virtual ~BReferenceable();
void AcquireReference();
int32 AcquireReference();
bool ReleaseReference();
// returns true after last

View File

@ -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;
}