mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-23 19:43:09 +00:00
add snax.self and snax.exit
This commit is contained in:
@@ -132,6 +132,14 @@ function snax.kill(obj, ...)
|
||||
skynet_call(obj.handle, "snax", t.system.exit, ...)
|
||||
end
|
||||
|
||||
function snax.self()
|
||||
return snax.bind(skynet.self(), SERVICE_NAME)
|
||||
end
|
||||
|
||||
function snax.exit(...)
|
||||
snax.kill(snax.self(), ...)
|
||||
end
|
||||
|
||||
local function test_result(ok, ...)
|
||||
if ok then
|
||||
return ...
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
local skynet = require "skynet"
|
||||
local queue = require "skynet.queue"
|
||||
local snax = require "snax"
|
||||
|
||||
local i = 0
|
||||
local hello = "hello"
|
||||
@@ -32,6 +33,10 @@ function accept.hello()
|
||||
end)
|
||||
end
|
||||
|
||||
function accept.exit(...)
|
||||
snax.exit(...)
|
||||
end
|
||||
|
||||
function response.error()
|
||||
error "throw an error"
|
||||
end
|
||||
|
||||
@@ -31,6 +31,6 @@ end
|
||||
print(string.format("%s\tcount:%d time:%f", name, v.count, v.time))
|
||||
end
|
||||
|
||||
print(snax.kill(ps,"exit"))
|
||||
print(ps.post.exit("exit")) -- == snax.kill(ps, "exit")
|
||||
skynet.exit()
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user