option for garbage-collector `step'

This commit is contained in:
Roberto Ierusalimschy
2004-06-04 12:30:53 -03:00
parent 118e471fa0
commit 345379b5ff
3 changed files with 17 additions and 18 deletions

11
lapi.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: lapi.c,v 2.9 2004/05/14 19:25:09 roberto Exp roberto $
** $Id: lapi.c,v 2.10 2004/05/31 19:41:52 roberto Exp roberto $
** Lua API
** See Copyright Notice in lua.h
*/
@@ -833,6 +833,15 @@ LUA_API int lua_gc (lua_State *L, int what, int data) {
/* GC values are expressed in Kbytes: #bytes/2^10 */
return cast(int, g->nblocks >> 10);
}
case LUA_GCSTEP: {
lu_mem a = (cast(lu_mem, data) << 10);
if (a <= g->nblocks)
g->GCthreshold = g->nblocks - a;
else
g->GCthreshold = 0;
luaC_step(L);
return 0;
}
default: return -1; /* invalid option */
}
}