Skip to content

Question: LState pooling #377

Answered by ZenLiuCN
szuecs asked this question in Q&A
Jun 16, 2021 · 8 comments · 2 replies
Discussion options

You must be logged in to vote

If I'm not miss understand, your question is about pooling, right?
As far as I see it's not a documented behavior that we can reuse LState in repo's readme there is an sample of pool.

  1. LState is not something ThreadSafe.
  2. LState is a lua vm instance.
  3. L.Push(L.NewFunctionFromProto(proto)) will create LFunction and push to stack
  4. L.PCall will execute on the stack, and then push result to stack if there are any.
    as function request(ctx, params) print(c.request.url); end there will no such action. check state.go:1970 you may see the implment.
  5. so it's safe in one LState to do such actions. and not need to do any resource release actions as I see.
func createScript(L *lua.LState, proto *lua.Fun…

Replies: 8 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by szuecs
Comment options

You must be logged in to vote
1 reply
@szuecs
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@szuecs
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #335 on April 30, 2022 10:39.