diff options
-rw-r--r-- | BehaviorTree/init.lua | 3 | ||||
-rw-r--r-- | StateMachine/init.lua | 3 | ||||
-rw-r--r-- | channels.lua | 6 | ||||
-rw-r--r-- | global.lua | 9 | ||||
-rw-r--r-- | main.lua | 21 | ||||
-rw-r--r-- | newton/init.lua | 2 | ||||
-rw-r--r-- | threadtest.lua | 10 |
7 files changed, 54 insertions, 0 deletions
diff --git a/BehaviorTree/init.lua b/BehaviorTree/init.lua new file mode 100644 index 0000000..79863bc --- /dev/null +++ b/BehaviorTree/init.lua @@ -0,0 +1,3 @@ +local BehaviorTree = {} + +return BehaviorTrees
\ No newline at end of file diff --git a/StateMachine/init.lua b/StateMachine/init.lua new file mode 100644 index 0000000..83daeb7 --- /dev/null +++ b/StateMachine/init.lua @@ -0,0 +1,3 @@ +local StateMachine = {} + +return StateMachine
\ No newline at end of file diff --git a/channels.lua b/channels.lua new file mode 100644 index 0000000..8139b9a --- /dev/null +++ b/channels.lua @@ -0,0 +1,6 @@ +local channels = { + "PROGRESS" + +} + +return CreatEnumTable(channels)
\ No newline at end of file diff --git a/global.lua b/global.lua new file mode 100644 index 0000000..c1094f9 --- /dev/null +++ b/global.lua @@ -0,0 +1,9 @@ + +function CreatEnumTable(tbl, index) + local enumtbl = {} + local enumindex = index or 0 + for i, v in ipairs(tbl) do + enumtbl[v] = enumindex + i + end + return enumtbl +end @@ -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 diff --git a/newton/init.lua b/newton/init.lua index 47781ff..41f9f9a 100644 --- a/newton/init.lua +++ b/newton/init.lua @@ -1,5 +1,7 @@ local newton = {} +newton.world = {} + newton.update = function(dt) end diff --git a/threadtest.lua b/threadtest.lua new file mode 100644 index 0000000..4568629 --- /dev/null +++ b/threadtest.lua @@ -0,0 +1,10 @@ +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
\ No newline at end of file |