File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,6 @@ package lua
3
3
import (
4
4
"context"
5
5
"fmt"
6
- "github.com/yuin/gopher-lua/parse"
7
6
"io"
8
7
"math"
9
8
"os"
@@ -12,6 +11,8 @@ import (
12
11
"sync"
13
12
"sync/atomic"
14
13
"time"
14
+
15
+ "github.com/yuin/gopher-lua/parse"
15
16
)
16
17
17
18
const MultRet = - 1
@@ -1212,6 +1213,10 @@ func NewState(opts ...Options) *LState {
1212
1213
return ls
1213
1214
}
1214
1215
1216
+ func (ls * LState ) IsClosed () bool {
1217
+ return ls .stack == nil
1218
+ }
1219
+
1215
1220
func (ls * LState ) Close () {
1216
1221
atomic .AddInt32 (& ls .stop , 1 )
1217
1222
for _ , file := range ls .G .tempFiles {
@@ -2016,7 +2021,7 @@ func (ls *LState) SetMx(mx int) {
2016
2021
go func () {
2017
2022
limit := uint64 (mx * 1024 * 1024 ) //MB
2018
2023
var s runtime.MemStats
2019
- for ls .stop == 0 {
2024
+ for atomic . LoadInt32 ( & ls .stop ) == 0 {
2020
2025
runtime .ReadMemStats (& s )
2021
2026
if s .Alloc >= limit {
2022
2027
fmt .Println ("out of memory" )
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ package lua
7
7
import (
8
8
"context"
9
9
"fmt"
10
- "github.com/yuin/gopher-lua/parse"
11
10
"io"
12
11
"math"
13
12
"os"
@@ -16,6 +15,8 @@ import (
16
15
"sync"
17
16
"sync/atomic"
18
17
"time"
18
+
19
+ "github.com/yuin/gopher-lua/parse"
19
20
)
20
21
21
22
const MultRet = - 1
@@ -2175,7 +2176,7 @@ func (ls *LState) SetMx(mx int) {
2175
2176
go func () {
2176
2177
limit := uint64 (mx * 1024 * 1024 ) //MB
2177
2178
var s runtime.MemStats
2178
- for ls .stop == 0 {
2179
+ for atomic . LoadInt32 ( & ls .stop ) == 0 {
2179
2180
runtime .ReadMemStats (& s )
2180
2181
if s .Alloc >= limit {
2181
2182
fmt .Println ("out of memory" )
You can’t perform that action at this time.
0 commit comments