Source file
test/fixedbugs/issue38093.go
1
2
3
4
5
6
7
8
9
10
11 package main
12
13 import (
14 "os"
15 "syscall/js"
16 "time"
17 )
18
19 func main() {
20 ch1 := make(chan struct{})
21
22 go func() {
23 for {
24 time.Sleep(5 * time.Millisecond)
25 ch1 <- struct{}{}
26 }
27 }()
28 go func() {
29 for {
30 time.Sleep(8 * time.Millisecond)
31 ch1 <- struct{}{}
32 }
33 }()
34 go func() {
35 time.Sleep(2 * time.Second)
36 os.Exit(0)
37 }()
38
39 for range ch1 {
40 ch2 := make(chan struct{}, 1)
41 f := js.FuncOf(func(this js.Value, args []js.Value) interface{} {
42 ch2 <- struct{}{}
43 return nil
44 })
45 defer f.Release()
46 fn := js.Global().Get("Function").New("cb", "cb();")
47 fn.Invoke(f)
48 <-ch2
49 }
50 }
51
View as plain text