diff options
author | chai <chaifix@163.com> | 2018-08-07 14:09:39 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-08-07 14:09:39 +0800 |
commit | aeba6ec617447143dcb27e0b60e3463252e24346 (patch) | |
tree | 51282da00eb8f85e724cdc899f70e429a8addba4 /main.lua | |
parent | d557097244f512acfdc2174383820180af9df01e (diff) |
*update
Diffstat (limited to 'main.lua')
-rw-r--r-- | main.lua | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -1,11 +1,28 @@ +require("global") local loghelper = require("loghelper") loghelper.strict(loghelper.LEVEL.INFO) local EventMsgCenter = require("EventMsgCenter.EventMsgCenter") local Events = require("EventMsgCenter.Events") local timer = require("timer.timer") +local channels = require("channels") _G["frame"] = 0 +local thread = nil + jin.core.onLoad = function() + thread = jin.thread.Thread("Test", [[ +require("global") +local channels = require("channels") + +local t = jin.thread.getThread() +local str = t:demand(channels.PROGRESS) +print(str) +t:send(3, "back data") +while true do + jin.time.sleep(1) +end + ]] ) + thread:start() EventMsgCenter.registerMsg(Events.Player_Move, function(msg) print(msg) end) @@ -13,8 +30,12 @@ jin.core.onLoad = function() loghelper.log(loghelper.LEVEL.INFO, _G["frame"] .. "fps") EventMsgCenter.sendMsg(Events.Player_Move, _G["frame"]) _G["frame"] = 0 + if thread:receive(3) then + print(thread:fetch(3)) + end end) timer.after(4.0, function() + thread:send(channels.PROGRESS, "test thread data") EventMsgCenter.unregisterAllMsgByEvent(Events.Player_Move) end) end |