add cluster.proxy and cluster.ncall

This commit is contained in:
Cloud Wu
2014-08-13 17:49:30 +08:00
parent cde423cb73
commit 978e010e67
11 changed files with 79 additions and 9 deletions

View File

@@ -99,6 +99,7 @@ local coroutine_yield = coroutine.yield
local function co_create(f)
local co = table.remove(coroutine_pool)
if co == nil then
local print = print
co = coroutine.create(function(...)
f(...)
while true do
@@ -548,7 +549,7 @@ end
function skynet.address(addr)
if type(addr) == "number" then
return string.format(":%x",addr)
return string.format(":%08x",addr)
else
return tostring(addr)
end
@@ -648,6 +649,21 @@ function skynet.filter(f ,start_func)
end)
end
function skynet.forward_type(map, start_func)
c.callback(function(ptype, msg, sz, ...)
local prototype = map[ptype]
if prototype then
dispatch_message(prototype, msg, sz, ...)
else
dispatch_message(ptype, msg, sz, ...)
c.trash(msg, sz)
end
end, true)
skynet.timeout(0, function()
init_service(start_func)
end)
end
function skynet.endless()
return c.command("ENDLESS")~=nil
end