add lock
This commit is contained in:
parent
16ae4fae3d
commit
36dbdd5d27
4
typed.go
4
typed.go
@ -36,6 +36,7 @@ var (
|
|||||||
stacks starmap.StarStack
|
stacks starmap.StarStack
|
||||||
stackStarted bool = false
|
stackStarted bool = false
|
||||||
stackStopChan chan int
|
stackStopChan chan int
|
||||||
|
stackMu sync.Mutex
|
||||||
stdScreen io.Writer = colorable.NewColorableStdout()
|
stdScreen io.Writer = colorable.NewColorableStdout()
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -145,11 +146,14 @@ func generateId() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func StartStacks() {
|
func StartStacks() {
|
||||||
|
stackMu.Lock()
|
||||||
if stackStarted {
|
if stackStarted {
|
||||||
|
stackMu.Unlock()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
stackStarted = true
|
stackStarted = true
|
||||||
|
stackMu.Unlock()
|
||||||
defer func() {
|
defer func() {
|
||||||
stackStarted = false
|
stackStarted = false
|
||||||
}()
|
}()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user