mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 20:23:06 +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, ...)
|
skynet_call(obj.handle, "snax", t.system.exit, ...)
|
||||||
end
|
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, ...)
|
local function test_result(ok, ...)
|
||||||
if ok then
|
if ok then
|
||||||
return ...
|
return ...
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
local skynet = require "skynet"
|
local skynet = require "skynet"
|
||||||
local queue = require "skynet.queue"
|
local queue = require "skynet.queue"
|
||||||
|
local snax = require "snax"
|
||||||
|
|
||||||
local i = 0
|
local i = 0
|
||||||
local hello = "hello"
|
local hello = "hello"
|
||||||
@@ -32,6 +33,10 @@ function accept.hello()
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function accept.exit(...)
|
||||||
|
snax.exit(...)
|
||||||
|
end
|
||||||
|
|
||||||
function response.error()
|
function response.error()
|
||||||
error "throw an error"
|
error "throw an error"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -31,6 +31,6 @@ end
|
|||||||
print(string.format("%s\tcount:%d time:%f", name, v.count, v.time))
|
print(string.format("%s\tcount:%d time:%f", name, v.count, v.time))
|
||||||
end
|
end
|
||||||
|
|
||||||
print(snax.kill(ps,"exit"))
|
print(ps.post.exit("exit")) -- == snax.kill(ps, "exit")
|
||||||
skynet.exit()
|
skynet.exit()
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user