require "log" require "sys" require "utils" require "patch" LOG_LEVEL=log.LOGLEVEL_TRACE local count = 0 local timer_id local function handle_once() log.info(nil,"timer once handle",os.date("%Y-%m-%d %H:%M:%S")) end local function handle_loop() count = count + 1 log.info(nil,"timer loop 5 times handle",os.date("%Y-%m-%d %H:%M:%S")) if count >= 5 then sys.timerStopAll(handle_loop) end end local function handle_loop2() log.info(nil,"timer loop once handle",os.date("%Y-%m-%d %H:%M:%S")) sys.timerStop(timer_id) end function main(nodes_cfg, sn) -- 启动系统框架 sys.init(0, 0) -- 如果不再task内不可以使用sys.wait ,需要延时需要使用 sleep/msleep log.info(nil,"timer once create",os.date("%Y-%m-%d %H:%M:%S")) sys.timerStart(handle_once,1000) sys.timerLoopStart(handle_loop,1000) timer_id = sys.timerLoopStart(handle_loop2,200) sys.run() end main()