Added mutexes to the GC and made tip buildable again on linux

This commit is contained in:
bart@bartbes.ath.cx
2010-05-20 17:31:07 +02:00
parent d48c28adec
commit 3d726b0dd9
4 changed files with 64 additions and 56 deletions
+1
View File
@@ -20,3 +20,4 @@
./modules/native/tcc/libtcc/coff.h ./modules/native/tcc/libtcc/coff.h
./modules/native/tcc/libtcc/stab.h ./modules/native/tcc/libtcc/stab.h
./libraries/luasocket/libluasocket/wsocket.* ./libraries/luasocket/libluasocket/wsocket.*
./modules/sound/lullaby/FLACDecoder.*
+8 -2
View File
@@ -29,19 +29,26 @@
// STD // STD
#include <iostream> #include <iostream>
// SDL
#include <SDL_mutex.h>
namespace love namespace love
{ {
static SDL_mutex *gcmutex = 0;
/** /**
* Called when an object is collected. The object is released * Called when an object is collected. The object is released
* once in this function, possibly deleting it. * once in this function, possibly deleting it.
**/ **/
static int w__gc(lua_State * L) static int w__gc(lua_State * L)
{ {
if (!gcmutex)
gcmutex = SDL_CreateMutex();
Proxy * p = (Proxy *)lua_touserdata(L, 1); Proxy * p = (Proxy *)lua_touserdata(L, 1);
Object * t = (Object *)p->data; Object * t = (Object *)p->data;
SDL_mutexP(gcmutex);
if(p->own) if(p->own)
t->release(); t->release();
SDL_mutexV(gcmutex);
return 0; return 0;
} }
@@ -414,5 +421,4 @@ namespace love
types.find(luaL_checkstring(L, idx), t); types.find(luaL_checkstring(L, idx), t);
return t; return t;
} }
} // love } // love
+1 -1
View File
@@ -209,7 +209,7 @@ namespace love
/** /**
* Converts an object into another object by the specified function love.module.function. * Converts an object into another object by the specified function love.module.function.
* The conversion function must accept a single object of the relevant type as a parameter, * The conversion function must accept a single object of the relevant type as a parameter,
* and return one value. If the function does not exist (see luax_getfunction), an error is returned. * and returnone value. If the function does not exist (see luax_getfunction), an error is returned.
* *
* Note that the initial object at idx is replaced by the new object. * Note that the initial object at idx is replaced by the new object.
* *
+1
View File
@@ -22,6 +22,7 @@
#include "ImageRasterizer.h" #include "ImageRasterizer.h"
#include <common/Exception.h> #include <common/Exception.h>
#include <string.h>
namespace love namespace love
{ {