Skip to content
New issue

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

[希望增加功能]隔离luathread #8

Open
lenglengai opened this issue Jul 20, 2016 · 3 comments
Open

[希望增加功能]隔离luathread #8

lenglengai opened this issue Jul 20, 2016 · 3 comments

Comments

@lenglengai
Copy link

创建luathread时我们希望不影响到主luastate希望增加隔离功能
示例代码如下:
luaState * sL = lua_newthread(L);
lua_pushthread(sL);
int luaRef = luaL_ref(sL, LUA_REGISTRYINDEX);

    lua_newtable(sL);
    lua_pushvalue(sL, -1);
    lua_setmetatable(sL, -2);

    lua_getglobal(sL,, "_G");
    lua_setfield(sL, -2, "__index");

    lua_pushvalue(sL, -1);
    lua_setglobal(sL, nName);

    lua_setupvalue(sL, -2, 1);
@yanwei1983
Copy link
Owner

你可以在你newthread时调用这个代码啊?
我看不出有任何必要需要在库中增加他

@lenglengai
Copy link
Author

好吧,这个随意吧,也许你平时没用到吧,
我只是觉得这是lua最重要核心功能,
比如插件的装载和卸载,界面的打开和关闭,
副本的打开和关闭,等等好多,
虽然我已经封装了我自己想要的东西
写上面那段代码毕竟花了我好几天时间专门研究lua这一小段功能,
可能很多人还要花很多时间再重写这段代码吧,
我只是想你已经做了那么多,为什么不加上呢?

不过谢谢你啊,最开始看到这个库,我真的很开心

@yanwei1983
Copy link
Owner

好的,请不要关闭这个issue,这样如果有人看到,那么刚好可以拿来使用

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants