Files
llgo/cl/_testdata/async/in.go

28 lines
340 B
Go
Raw Normal View History

2024-08-05 20:21:11 +08:00
package async
2024-08-04 09:54:34 +08:00
import (
"github.com/goplus/llgo/x/async"
)
func GenInts() (co *async.Promise[int]) {
co.Yield(1)
co.Yield(2)
co.Yield(3)
return
}
func WrapGenInts() *async.Promise[int] {
return GenInts()
}
func UseGenInts() int {
co := WrapGenInts()
r := 0
for !co.Done() {
v := co.Value()
r += v
co.Next()
2024-08-04 09:54:34 +08:00
}
return r
}