local threadm = {}
local threadi = {}
+local _meta = {__mode = "k"}
+setmetatable(threadm, _meta)
+setmetatable(threadi, _meta)
+
+
function Socket(ip, port)
local sock, err = socket.bind( ip, port )
function step()
local idle = true
-
if not THREAD_LIMIT or threadc < THREAD_LIMIT then
local now = os.time()
for i, server in ipairs(reading) do
coroutine.resume(thread, client)
local now = os.time()
if coroutine.status(thread) == "dead" then
- threads[client] = nil
threadc = threadc - 1
+ threads[client] = nil
elseif threadm[client] and threadm[client] + THREAD_TIMEOUT < now then
threads[client] = nil
threadc = threadc - 1
end
if idle then
+ collectgarbage()
socket.sleep(THREAD_IDLEWAIT)
end
-end
\ No newline at end of file
+end