Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected channel behavior #694

Open
spongehah opened this issue Aug 9, 2024 · 0 comments
Open

Unexpected channel behavior #694

spongehah opened this issue Aug 9, 2024 · 0 comments

Comments

@spongehah
Copy link
Contributor

spongehah commented Aug 9, 2024

For the following code, there may be two running results:
@luoliwoshang verified and obtained consistent results.

package main

import (
	"github.com/goplus/llgo/c"
)

func main() {
	res := make(chan struct{})
	done := make(chan struct{})
	go func() {
		println("go")
		//time.Sleep(4 * time.Second)
		//c.Usleep(4 * 1000 * 1000)
		select {
		case <-res:
			println("res")
		case <-done:
			println("done")
		}
	}()

	res <- struct{}{}
	c.Usleep(2 * 1000 * 1000)
	//time.Sleep(2 * time.Second)
}
(base) ~/go/src/llgo/x git:[refactor/c-libuv-remove-go-wrapper]
llgo run test.go
go
res
(base) ~/go/src/llgo/x git:[refactor/c-libuv-remove-go-wrapper]
llgo run test.go
go

environment:

(base) ~/go/src/llgo/x git:[refactor/c-libuv-remove-go-wrapper]
go version
go version go1.21.4 darwin/amd64

(base) ~/go/src/llgo/x git:[refactor/c-libuv-remove-go-wrapper]
uname -a
Darwin MacBook.local 22.6.0 Darwin Kernel Version 22.6.0: Mon Apr 22 20:54:28 PDT 2024; root:xnu-8796.141.3.705.2~1/RELEASE_X86_64 x86_64

(base) ~/go/src/llgo/x git:[refactor/c-libuv-remove-go-wrapper]
clang --version
Apple clang version 14.0.3 (clang-1403.0.22.14.1)
Target: x86_64-apple-darwin22.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant