浏览代码

option to return GC to normal (incremental, non generational) mode

Roberto Ierusalimschy 15 年之前
父节点
当前提交
11126422d9
共有 3 个文件被更改,包括 11 次插入5 次删除
  1. 5 1
      lapi.c
  2. 4 3
      lbaselib.c
  3. 2 1
      lua.h

+ 5 - 1
lapi.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lapi.c,v 2.117 2010/03/26 20:58:11 roberto Exp roberto $
+** $Id: lapi.c,v 2.118 2010/03/29 17:43:14 roberto Exp roberto $
 ** Lua API
 ** Lua API
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -952,6 +952,10 @@ LUA_API int lua_gc (lua_State *L, int what, int data) {
       g->gckind = KGC_GEN;
       g->gckind = KGC_GEN;
       break;
       break;
     }
     }
+    case LUA_GCINC: {  /* change collector to incremental mode */
+      g->gckind = KGC_NORMAL;
+      break;
+    }
     default: res = -1;  /* invalid option */
     default: res = -1;  /* invalid option */
   }
   }
   lua_unlock(L);
   lua_unlock(L);

+ 4 - 3
lbaselib.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lbaselib.c,v 1.239 2010/03/22 18:28:03 roberto Exp roberto $
+** $Id: lbaselib.c,v 1.240 2010/03/26 20:58:11 roberto Exp roberto $
 ** Basic library
 ** Basic library
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -148,10 +148,11 @@ static int luaB_gcinfo (lua_State *L) {
 
 
 static int luaB_collectgarbage (lua_State *L) {
 static int luaB_collectgarbage (lua_State *L) {
   static const char *const opts[] = {"stop", "restart", "collect",
   static const char *const opts[] = {"stop", "restart", "collect",
-    "count", "step", "setpause", "setstepmul", "isrunning", "gen", NULL};
+    "count", "step", "setpause", "setstepmul", "isrunning",
+    "gen", "inc", NULL};
   static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT,
   static const int optsnum[] = {LUA_GCSTOP, LUA_GCRESTART, LUA_GCCOLLECT,
     LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL,
     LUA_GCCOUNT, LUA_GCSTEP, LUA_GCSETPAUSE, LUA_GCSETSTEPMUL,
-    LUA_GCISRUNNING, LUA_GCGEN};
+    LUA_GCISRUNNING, LUA_GCGEN, LUA_GCINC};
   int o = optsnum[luaL_checkoption(L, 1, "collect", opts)];
   int o = optsnum[luaL_checkoption(L, 1, "collect", opts)];
   int ex = luaL_optint(L, 2, 0);
   int ex = luaL_optint(L, 2, 0);
   int res = lua_gc(L, o, ex);
   int res = lua_gc(L, o, ex);

+ 2 - 1
lua.h

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lua.h,v 1.264 2010/03/22 18:28:03 roberto Exp roberto $
+** $Id: lua.h,v 1.265 2010/03/26 20:58:11 roberto Exp roberto $
 ** Lua - A Scripting Language
 ** Lua - A Scripting Language
 ** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
 ** Lua.org, PUC-Rio, Brazil (http://www.lua.org)
 ** See Copyright Notice at the end of this file
 ** See Copyright Notice at the end of this file
@@ -267,6 +267,7 @@ LUA_API int  (lua_status) (lua_State *L);
 #define LUA_GCSETSTEPMUL	7
 #define LUA_GCSETSTEPMUL	7
 #define LUA_GCISRUNNING		8
 #define LUA_GCISRUNNING		8
 #define LUA_GCGEN		9
 #define LUA_GCGEN		9
+#define LUA_GCINC		10
 
 
 LUA_API int (lua_gc) (lua_State *L, int what, int data);
 LUA_API int (lua_gc) (lua_State *L, int what, int data);