mirror of
https://github.com/Open-Argon/argon-v3.git
synced 2025-12-06 08:56:07 +00:00
wait for threads to complete
This commit is contained in:
@@ -66,4 +66,7 @@ func main() {
|
|||||||
panicErr(err)
|
panicErr(err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
if threadCount > 0 {
|
||||||
|
<-threadChan
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var threadCount = 0
|
||||||
|
var threadChan = make(chan bool)
|
||||||
|
|
||||||
func ArThread(args ...any) (any, ArErr) {
|
func ArThread(args ...any) (any, ArErr) {
|
||||||
if len(args) != 1 {
|
if len(args) != 1 {
|
||||||
return nil, ArErr{TYPE: "TypeError", message: "Invalid number of arguments, expected 1, got " + fmt.Sprint(len(args)), EXISTS: true}
|
return nil, ArErr{TYPE: "TypeError", message: "Invalid number of arguments, expected 1, got " + fmt.Sprint(len(args)), EXISTS: true}
|
||||||
@@ -36,8 +39,13 @@ func ArThread(args ...any) (any, ArErr) {
|
|||||||
}
|
}
|
||||||
hasrun = true
|
hasrun = true
|
||||||
go func() {
|
go func() {
|
||||||
|
threadCount++
|
||||||
resp, err = runCall(call{Callable: tocall, Args: []any{}}, nil, 0)
|
resp, err = runCall(call{Callable: tocall, Args: []any{}}, nil, 0)
|
||||||
wg <- true
|
wg <- true
|
||||||
|
threadCount--
|
||||||
|
if threadCount == 0 {
|
||||||
|
threadChan <- true
|
||||||
|
}
|
||||||
}()
|
}()
|
||||||
return nil, ArErr{}
|
return nil, ArErr{}
|
||||||
}},
|
}},
|
||||||
|
|||||||
Reference in New Issue
Block a user