multicast dispatch map should be weak

This commit is contained in:
Cloud Wu
2014-04-30 12:23:15 +08:00
parent 1c2654e117
commit 4a92dfaa65

View File

@@ -3,17 +3,12 @@ local mc = require "multicast.c"
local multicastd
local multicast = {}
local dispatch = {}
local dispatch = setmetatable({} , {__mode = "kv" })
local chan = {}
local chan_meta = {
__index = chan,
__gc = function(self)
self:unsubscribe()
local c = self.channel
self.channel = nil
dispatch[c] = nil
end,
__gc = unsubscribe,
__tostring = function (self)
return string.format("[Multicast:%x]",self.channel)
end,