Conversation
Contributor
|
@cloudwu 把ud保存到lua状态机中,如skynet_context*,用这种方式比upvalue的方式性能高一些 //save
lua_newstate(alloc, context)
//get
struct skynet_context* context = nullptr;
lua_getallocf(L, &context); |
Owner
Author
|
这种不通用。 |
Contributor
确实不通用,但对于某些情形比较好用 ,就是类似存 skyenet skynet_context*, ltask ltask* 这种。 |
Contributor
|
我有种方案不知道对于skynet 是否可行 struct snlua {
struct skynet_context * ctx;//放在第一位, 强转 ud 到 skynet_context*
lua_State * L;
size_t mem;
size_t mem_report;
size_t mem_limit;
lua_State * activeL;
ATOM_INT trap;
}; |
Owner
Author
|
没必要混在一起。skynet_context 是 service 层面的东西,和 lua 库不是一个层面。它们之间不应该共享知识。 |
Contributor
嗯,但skynet相关的 lua-clib 确实依赖 skynet_context 和c层交互 |
Owner
Author
|
skynet 这个 C 库不应和别的 C 库有什么区别。 理论上你可以 link 一个有 skynet_context 的东西去模拟其行为,例如记录下所有消息并回放。 最重要的是:“性能" 不是做这些事情的理由。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.