timer.lua 238 B

1234567891011121314
  1. local skynet = require "skynet"
  2. local function timer(ti, listener)
  3. local delete = function()
  4. listener = nil
  5. end
  6. skynet.timeout(ti, function()
  7. if listener then
  8. listener()
  9. end
  10. end)
  11. return delete
  12. end
  13. return timer