mirror of
https://github.com/love2d/love.git
synced 2026-08-14 01:20:56 +02:00
Reference counting for love objects in 0.9.2 is now atomic (using SDL's atomic operation functions.)
This commit is contained in:
@@ -21,33 +21,31 @@
|
||||
// LOVE
|
||||
#include "Object.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
namespace love
|
||||
{
|
||||
|
||||
Object::Object()
|
||||
: count(1)
|
||||
{
|
||||
count.value = 1;
|
||||
}
|
||||
|
||||
Object::~Object()
|
||||
{
|
||||
}
|
||||
|
||||
int Object::getReferenceCount() const
|
||||
int Object::getReferenceCount()
|
||||
{
|
||||
return count;
|
||||
return SDL_AtomicGet(&count);
|
||||
}
|
||||
|
||||
void Object::retain()
|
||||
{
|
||||
++count;
|
||||
SDL_AtomicIncRef(&count);
|
||||
}
|
||||
|
||||
void Object::release()
|
||||
{
|
||||
if (--count <= 0)
|
||||
if (SDL_AtomicDecRef(&count))
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user