We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
alex, 我觉得在luactor中没必要把消息约定为msg, 而是以...直接给出接口更优雅
actor.send('foo', 'f', 'test1', 'test2')
actor.wait({ f = function(sender, ...) local v1, v2 = ... print(v1, v2) end })
;-)
The text was updated successfully, but these errors were encountered:
的确更优雅,但是主要有个缺点就是没法传递KV类型的值,只能传递列表。如果是python就没有这个限制。
Sorry, something went wrong.
alex, 上次讨论多个coroutine在并行环境下的消息传递, 这几天阅读skynet, 和PIL是这样的:(不知道说的对不对)
首先lua是不支持在多线程跑多个coroutine的, 在多线程情况下, 要开多个lua VM, 也就是多个lua_State
要想让多个lua_State之间传递消息, skynet提供了两套pack/unpack方案, 一种是string, 一种是由云风用自己的lua-serialize实现修改而来的, lua-serialize ,但skynet并不强制约定打包方案。而是由框架提供的打包函数提供的。
下面的"..."参数打包后返回一个lightuserdata和一个整数size
lua local lightuserdata, size = skynet.pack(...)
lua
解包就是 ``` lua``` skynet.unpack(lightuserdata, size)
lightuserdata和size的传递是通过框架的
lua skynet.send(lightuserdata, size)
解包之后lightuserdata并没有被释放了, 释放发生在callback调用完成之后。 这个在skynet底层做了。 云风的skynet, 使用一个叫做snlua C服务承载lua服务, 每个lua服务可以开多个协程, 但这些coroutine共享一个callback函数, 因此skynet lua库利用session和type提供了lua层的message dispach
No branches or pull requests
alex, 我觉得在luactor中没必要把消息约定为msg, 而是以...直接给出接口更优雅
actor.send('foo', 'f', 'test1', 'test2')
actor.wait({
f = function(sender, ...)
local v1, v2 = ...
print(v1, v2)
end
})
;-)
The text was updated successfully, but these errors were encountered: