util.timer: Defer to selected net.server if it implements this API
authorKim Alvefur <zash@zash.se>
Mon, 29 Jun 2020 16:37:58 +0200
changeset 10985 e6c1e92cc7a7
parent 10984 eaee72c7afbd
child 10986 276f16101d59
util.timer: Defer to selected net.server if it implements this API E.g. net.server_epoll is very close and could easily be adapted to support this.
util/timer.lua
--- a/util/timer.lua	Mon Jun 29 12:51:28 2020 +0100
+++ b/util/timer.lua	Mon Jun 29 16:37:58 2020 +0200
@@ -16,6 +16,11 @@
 local xpcall = require "util.xpcall".xpcall;
 local math_max = math.max;
 
+if server.timer then
+	-- The selected net.server implements this API, so defer to that
+	return server.timer;
+end
+
 local _ENV = nil;
 -- luacheck: std none