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)
|
||||
os.Exit(1)
|
||||
}
|
||||
if threadCount > 0 {
|
||||
<-threadChan
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,9 @@ import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var threadCount = 0
|
||||
var threadChan = make(chan bool)
|
||||
|
||||
func ArThread(args ...any) (any, ArErr) {
|
||||
if len(args) != 1 {
|
||||
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
|
||||
go func() {
|
||||
threadCount++
|
||||
resp, err = runCall(call{Callable: tocall, Args: []any{}}, nil, 0)
|
||||
wg <- true
|
||||
threadCount--
|
||||
if threadCount == 0 {
|
||||
threadChan <- true
|
||||
}
|
||||
}()
|
||||
return nil, ArErr{}
|
||||
}},
|
||||
|
||||
Reference in New Issue
Block a user