c/pthread/sync.Once

This commit is contained in:
xushiwei
2024-06-17 12:14:24 +08:00
parent a819796ce2
commit 72274bda82
6 changed files with 122 additions and 1 deletions

19
cl/_testlibc/once/in.go Normal file
View File

@@ -0,0 +1,19 @@
package main
import (
"github.com/goplus/llgo/c"
"github.com/goplus/llgo/c/pthread/sync"
)
var once sync.Once = sync.OnceInit
func f() {
once.Do(func() {
c.Printf(c.Str("Do once\n"))
})
}
func main() {
f()
f()
}