Replies: 4 comments 3 replies
-
功能等价,使用方式侧重点不同
task框架介绍:https://wiki.luatos.com/luaGuide/luatask.html
…---原始邮件---
发件人: "Eric ***@***.***>
发送时间: 2023年4月19日(周三) 中午11:24
收件人: ***@***.***>;
抄送: ***@***.***>;
主题: [chenxuuu/llcom] 关于luatask框架的waitUntil和subscribe用法区别 (Discussion #130)
sys.taskInit(function() while true do local result, data = sys.waitUntil("TASK1_DONE")--等待这个消息,这个任务阻塞在这里了 log.info("task", result, data) end end)
sys.subscribe("TASK1_DONE",function(data) log.info("subscribe", data) end)
请教下以上两种方式有什么区别,比如使用场景,效率等。目前来看功能上似乎是等价的。
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
-
waituntil是协程里用的,可以在用异步的同时保持顺序执行的逻辑
subscribe是回调试的逻辑,有时也会有需求
…---原始邮件---
发件人: "Eric ***@***.***>
发送时间: 2023年4月19日(周三) 中午11:24
收件人: ***@***.***>;
抄送: ***@***.***>;
主题: [chenxuuu/llcom] 关于luatask框架的waitUntil和subscribe用法区别 (Discussion #130)
sys.taskInit(function() while true do local result, data = sys.waitUntil("TASK1_DONE")--等待这个消息,这个任务阻塞在这里了 log.info("task", result, data) end end)
sys.subscribe("TASK1_DONE",function(data) log.info("subscribe", data) end)
请教下以上两种方式有什么区别,比如使用场景,效率等。目前来看功能上似乎是等价的。
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
-
原版逻辑和我移植的不太一样,你说的问题你可以试试
…---原始邮件---
发件人: "Eric ***@***.***>
发送时间: 2023年4月19日(周三) 中午11:53
收件人: ***@***.***>;
抄送: ***@***.******@***.***>;
主题: Re: [chenxuuu/llcom] 关于luatask框架的waitUntil和subscribe用法区别 (Discussion #130)
function sys.publish(...) arg = { ... } table.insert(messageQueue, arg) dispatch() -- 这里在rtos版本中没有 end
llcom工具的sys.lua代码中,这个地方跟rtos版本有区别,这里的写法不是异步逻辑了吧。
个人理解,如果在subscribe回调中又调publish是不是可能会导致嵌套执行跑死?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
-
你这死循环那当然。。。
…---原始邮件---
发件人: "Eric ***@***.***>
发送时间: 2023年4月19日(周三) 中午12:07
收件人: ***@***.***>;
抄送: ***@***.******@***.***>;
主题: Re: [chenxuuu/llcom] 关于luatask框架的waitUntil和subscribe用法区别 (Discussion #130)
sys.subscribe("TASK1_DONE",function(data) log.info("subscribe", data) sys.publish("TASK1_DONE", 0) --加这一句 end)
我试了,很快就跑死了
2023-04-19 12:02:42.881 +08:00 [INF] [E]-[task] run failed
D:\Software\llcom\core_script/sys.lua:296: D:\Software\llcom\core_script/sys.lua:280: C stack overflow,hex:443A5C536F6674776172655C6C6C636F6D5C636F72655F7363726970742F7379732E6C75613A3238303A204320737461636B206F766572666C6F77
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you commented.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
sys.taskInit(function() while true do local result, data = sys.waitUntil("TASK1_DONE")--等待这个消息,这个任务阻塞在这里了 log.info("task", result, data) end end)
sys.subscribe("TASK1_DONE",function(data) log.info("subscribe", data) end)
请教下以上两种方式有什么区别,比如使用场景,效率等。目前来看功能上似乎是等价的。
Beta Was this translation helpful? Give feedback.
All reactions