/** * Stops the timer so it won't be called by the specified event loop. * * Usage: * timer:stop(loop) * * [+0, -0, e] */ static int timer_stop(lua_State *L) { ev_timer* timer = check_timer(L, 1); struct ev_loop* loop = *check_loop_and_init(L, 2); loop_stop_watcher(L, 2, 1); ev_timer_stop(loop, timer); return 0; }
/** * Stops the idle so it won't be called by the specified event loop. * * Usage: * idle:stop(loop) * * [+0, -0, e] */ static int idle_stop(lua_State *L) { ev_idle* idle = check_idle(L, 1); struct ev_loop* loop = *check_loop_and_init(L, 2); loop_stop_watcher(L, 2, 1); ev_idle_stop(loop, idle); return 0; }
/** * Stops the io so it won't be called by the specified event loop. * * Usage: * io:stop(loop) * * [+0, -0, e] */ static int io_stop(lua_State *L) { ev_io* io = check_io(L, 1); struct ev_loop* loop = *check_loop_and_init(L, 2); loop_stop_watcher(L, 2, 1); ev_io_stop(loop, io); return 0; }
/** * Stops the child so it won't be called by the specified event loop. * * Usage: * child:stop(loop) * * [+0, -0, e] */ static int child_stop(lua_State *L) { ev_child* child = check_child(L, 1); struct ev_loop* loop = *check_loop_and_init(L, 2); loop_stop_watcher(L, loop, GET_WATCHER_DATA(child), 1); ev_child_stop(loop, child); return 0; }
/** * Starts the idle so it won't be called by the specified event loop. * * Usage: * idle:start(loop [, is_daemon]) * * [+0, -0, e] */ static int idle_start(lua_State *L) { ev_idle* idle = check_idle(L, 1); struct ev_loop* loop = *check_loop_and_init(L, 2); int is_daemon = lua_toboolean(L, 3); ev_idle_start(loop, idle); loop_start_watcher(L, 2, 1, is_daemon); return 0; }
/** * Starts the timer so it won't be called by the specified event loop. * * Usage: * timer:start(loop [, is_daemon]) * * [+0, -0, e] */ static int timer_start(lua_State *L) { ev_timer* timer = check_timer(L, 1); struct ev_loop* loop = *check_loop_and_init(L, 2); int is_daemon = lua_toboolean(L, 3); ev_timer_start(loop, timer); loop_start_watcher(L, 2, 1, is_daemon); return 0; }
/** * Starts the child so it will be called by the specified event loop. * * Usage: * child:start(loop [, is_daemon]) * * [+0, -0, e] */ static int child_start(lua_State *L) { ev_child* child = check_child(L, 1); struct ev_loop* loop = *check_loop_and_init(L, 2); int is_daemon = lua_toboolean(L, 3); ev_child_start(loop, child); loop_start_watcher(L, loop, GET_WATCHER_DATA(child), 2, 1, is_daemon); return 0; }
/** * If the timer is pending, return the revents and clear the pending * status (so the timer callback won't be called). * * Usage: * revents = timer:clear_pending(loop) * * [+1, -0, e] */ static int timer_clear_pending(lua_State *L) { ev_timer* timer = check_timer(L, 1); struct ev_loop* loop = *check_loop_and_init(L, 2); int revents = ev_clear_pending(loop, timer); if ( ! timer->repeat && ( revents & EV_TIMEOUT ) ) { loop_stop_watcher(L, 2, 1); } lua_pushnumber(L, revents); return 1; }
/** * Restart a timer with the specified repeat number of seconds. If no * repeat was specified, the timer is simply stopped. May optionally * specify a new value for repeat, otherwise uses the value set when * the timer was created. * * 1 - timer object. * 2 - loop object. * 3 - repeat (number of seconds to wait for consecutive timeouts). * * Usage: * timer:again(loop [, repeat_seconds]) * * [+0, -0, e] */ static int timer_again(lua_State *L) { ev_timer* timer = check_timer(L, 1); struct ev_loop* loop = *check_loop_and_init(L, 2); ev_tstamp repeat = luaL_optnumber(L, 3, 0); if ( repeat < 0.0 ) luaL_argerror(L, 3, "repeat must be greater than 0"); if ( repeat ) timer->repeat = repeat; if ( timer->repeat ) { ev_timer_again(loop, timer); loop_start_watcher(L, 2, 1, -1); } else { /* Just calling stop instead of again in case the symantics * change in libev */ loop_stop_watcher(L, 2, 1); ev_timer_stop(loop, timer); } return 0; }
/** * If the watcher is pending, return the revents and clear the pending * status (so the watcher callback won't be called). * * Usage: * revents = watcher:clear_pending(loop) * * [+1, -0, e] */ static int watcher_clear_pending(lua_State *L) { lua_pushnumber(L, ev_clear_pending(*check_loop_and_init(L, 2), check_watcher(L, 1))); return 1; }