libubox: allow reading out the remaining time of a uloop timer in Lua
Add Lua method to the uloop wrapper to allow reading out the remaining time of a uloop timer Signed-off-by: Stijn Cleynhens <stijncleynhens@gmail.com>
This commit is contained in:
parent
77a629375d
commit
f9db1cb918
1 changed files with 10 additions and 0 deletions
10
lua/uloop.c
10
lua/uloop.c
|
@ -94,6 +94,15 @@ static int ul_timer_set(lua_State *L)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int ul_timer_remaining(lua_State *L)
|
||||||
|
{
|
||||||
|
struct lua_uloop_timeout *tout;
|
||||||
|
|
||||||
|
tout = lua_touserdata(L, 1);
|
||||||
|
lua_pushnumber(L, uloop_timeout_remaining(&tout->t));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int ul_timer_free(lua_State *L)
|
static int ul_timer_free(lua_State *L)
|
||||||
{
|
{
|
||||||
struct lua_uloop_timeout *tout = lua_touserdata(L, 1);
|
struct lua_uloop_timeout *tout = lua_touserdata(L, 1);
|
||||||
|
@ -114,6 +123,7 @@ static int ul_timer_free(lua_State *L)
|
||||||
|
|
||||||
static const luaL_Reg timer_m[] = {
|
static const luaL_Reg timer_m[] = {
|
||||||
{ "set", ul_timer_set },
|
{ "set", ul_timer_set },
|
||||||
|
{ "remaining", ul_timer_remaining },
|
||||||
{ "cancel", ul_timer_free },
|
{ "cancel", ul_timer_free },
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue