Add more garbage collector functions
This commit is contained in:
parent
9f63b1e90d
commit
5b7b930485
|
@ -384,6 +384,18 @@ pub const Lua = struct {
|
|||
return c.lua_gc(lua.state, c.LUA_GCSETSTEPMUL, multiplier);
|
||||
}
|
||||
|
||||
pub fn gcIsRunning(lua: *Lua) bool {
|
||||
return c.lua_gc(lua.state, c.LUA_GCISRUNNING, 0) == 1;
|
||||
}
|
||||
|
||||
pub fn gcSetGoal(lua: *Lua, goal: i32) i32 {
|
||||
return c.lua_gc(lua.state, c.LUA_GCSETGOAL, goal);
|
||||
}
|
||||
|
||||
pub fn gcSetStepSize(lua: *Lua, size: i32) i32 {
|
||||
return c.lua_gc(lua.state, c.LUA_GCSETSTEPSIZE, size);
|
||||
}
|
||||
|
||||
/// Returns the memory allocation function of a given state
|
||||
/// If data is not null, it is set to the opaque pointer given when the allocator function was set
|
||||
/// See https://www.lua.org/manual/5.1/manual.html#lua_getallocf
|
||||
|
|
|
@ -421,9 +421,12 @@ test "garbage collector" {
|
|||
lua.gcCollect();
|
||||
lua.gcRestart();
|
||||
lua.gcStep();
|
||||
_ = lua.gcIsRunning();
|
||||
_ = lua.gcCount();
|
||||
_ = lua.gcCountB();
|
||||
_ = lua.gcSetGoal(10);
|
||||
_ = lua.gcSetStepMul(2);
|
||||
_ = lua.gcSetStepSize(1);
|
||||
}
|
||||
|
||||
test "table access" {
|
||||
|
|
Loading…
Reference in New Issue
Block a user