Fixed race condition in Release(), supplied by Marcus Overhangen.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1529 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -57,15 +57,14 @@ public:
|
|||||||
// dtor should be private, but ie. ObjectList requires a public dtor!
|
// dtor should be private, but ie. ObjectList requires a public dtor!
|
||||||
virtual ~Object() { };
|
virtual ~Object() { };
|
||||||
|
|
||||||
// thread-safe as long as thread that calls acquire has already
|
// thread-safe as long as thread that calls Acquire has already
|
||||||
// a reference to the object
|
// a reference to the object
|
||||||
void Acquire() {
|
void Acquire() {
|
||||||
atomic_add(&fRefCount, 1);
|
atomic_add(&fRefCount, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Release() {
|
bool Release() {
|
||||||
atomic_add(&fRefCount, -1);
|
if (atomic_add(&fRefCount, -1) == 1) {
|
||||||
if (fRefCount == 0) {
|
|
||||||
delete this; return true;
|
delete this; return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user