Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Installation

go get github.com/yuin/gopher-lua

GopherLua supports >= Go1.9.
GopherLua supports >= Go1.20.

----------------------------------------------------------------
Usage
Expand Down
10 changes: 3 additions & 7 deletions _state.go
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,6 @@ func newLState(options Options) *LState {
wrapped: false,
uvcache: nil,
hasErrorFunc: false,
mainLoop: mainLoop,
ctx: nil,
}
if options.MinimizeStackMemory {
Expand Down Expand Up @@ -1051,9 +1050,9 @@ func (ls *LState) callR(nargs, nret, rbase int) {
if ls.G.MainThread == nil {
ls.G.MainThread = ls
ls.G.CurrentThread = ls
ls.mainLoop(ls, nil)
mainLoop(ls, nil)
} else {
ls.mainLoop(ls, ls.currentFrame)
mainLoop(ls, ls.currentFrame)
}
if nret != MultRet {
ls.reg.SetTop(rbase + nret)
Expand Down Expand Up @@ -1404,7 +1403,6 @@ func (ls *LState) NewThread() (*LState, context.CancelFunc) {
thread.Env = ls.Env
var f context.CancelFunc = nil
if ls.ctx != nil {
thread.mainLoop = mainLoopWithContext
thread.ctx, f = context.WithCancel(ls.ctx)
thread.ctxCancelFn = f
}
Expand Down Expand Up @@ -2044,9 +2042,8 @@ func (ls *LState) SetMx(mx int) {
}()
}

// SetContext set a context ctx to this LState. The provided ctx must be non-nil.
// SetContext set a context ctx to this LState.
func (ls *LState) SetContext(ctx context.Context) {
ls.mainLoop = mainLoopWithContext
ls.ctx = ctx
}

Expand All @@ -2058,7 +2055,6 @@ func (ls *LState) Context() context.Context {
// RemoveContext removes the context associated with this LState and returns this context.
func (ls *LState) RemoveContext() context.Context {
oldctx := ls.ctx
ls.mainLoop = mainLoop
ls.ctx = nil
return oldctx
}
Expand Down
Loading