mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
bugfix: skynet.exit redirect error, and add datacenter.wait
This commit is contained in:
23
test/testdatacenter.lua
Normal file
23
test/testdatacenter.lua
Normal file
@@ -0,0 +1,23 @@
|
||||
local skynet = require "skynet"
|
||||
local datacenter = require "datacenter"
|
||||
|
||||
local function f1()
|
||||
print("====1==== wait hello")
|
||||
print("\t1>",datacenter.wait ("hello"))
|
||||
print("====1==== wait key.foobar")
|
||||
print("\t1>", pcall(datacenter.wait,"key")) -- will failed, because "key" is a branch
|
||||
print("\t1>",datacenter.wait ("key", "foobar"))
|
||||
end
|
||||
|
||||
local function f2()
|
||||
skynet.sleep(10)
|
||||
print("====2==== set key.foobar")
|
||||
datacenter.set("key", "foobar", "bingo")
|
||||
end
|
||||
|
||||
skynet.start(function()
|
||||
datacenter.set("hello", "world")
|
||||
print(datacenter.get "hello")
|
||||
skynet.fork(f1)
|
||||
skynet.fork(f2)
|
||||
end)
|
||||
Reference in New Issue
Block a user