Adjust ReleaseReference() to also return the previous ref count as

AcquireReference() now does, and adjust all callers that relied on the previous
return type.



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@42091 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Rene Gollent 2011-06-10 22:31:33 +00:00
parent d73d70971b
commit 8c3c117201
4 changed files with 9 additions and 8 deletions

View File

@ -17,9 +17,10 @@ public:
BReferenceable();
virtual ~BReferenceable();
// acquire and release return
// the previous ref count
int32 AcquireReference();
bool ReleaseReference();
// returns true after last
int32 ReleaseReference();
int32 CountReferences() const
{ return fReferenceCount; }

View File

@ -2789,7 +2789,7 @@ ClientConnection::_PutVolume(ClientVolume* volume)
// decrement reference counter and remove the volume, if 0
AutoLocker<VolumeMap> locker(fVolumes);
bool removed = (volume->ReleaseReference() && volume->IsRemoved());
bool removed = (volume->ReleaseReference() == 1 && volume->IsRemoved());
if (removed)
fVolumes->Remove(volume->GetID());
locker.Unlock();

View File

@ -253,7 +253,7 @@ NetAddressResolver::~NetAddressResolver()
{
if (fResolver) {
_Lock();
if (sResolver->ReleaseReference()) {
if (sResolver->ReleaseReference() == 1) {
delete sResolver;
sResolver = NULL;
}

View File

@ -41,14 +41,14 @@ BReferenceable::AcquireReference()
}
bool
int32
BReferenceable::ReleaseReference()
{
bool unreferenced = (atomic_add(&fReferenceCount, -1) == 1);
int32 previousReferenceCount = atomic_add(&fReferenceCount, -1);
TRACE("%p: release %ld\n", this, fReferenceCount);
if (unreferenced)
if (previousReferenceCount == 1)
LastReferenceReleased();
return unreferenced;
return previousReferenceCount;
}