runtime: goexit use thread key
This commit is contained in:
57
compiler/cl/_testgo/goexit/in.go
Normal file
57
compiler/cl/_testgo/goexit/in.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
)
|
||||
|
||||
func main() {
|
||||
demo1()
|
||||
demo2()
|
||||
demo3()
|
||||
}
|
||||
|
||||
func demo1() {
|
||||
ch := make(chan bool)
|
||||
go func() {
|
||||
defer func() {
|
||||
ch <- true
|
||||
}()
|
||||
runtime.Goexit()
|
||||
}()
|
||||
<-ch
|
||||
}
|
||||
|
||||
func demo2() {
|
||||
ch := make(chan bool)
|
||||
go func() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
panic("must nil")
|
||||
}
|
||||
ch <- true
|
||||
}()
|
||||
runtime.Goexit()
|
||||
}()
|
||||
<-ch
|
||||
}
|
||||
|
||||
func demo3() {
|
||||
ch := make(chan bool)
|
||||
go func() {
|
||||
defer func() {
|
||||
r := recover()
|
||||
if r != "error" {
|
||||
panic("must error")
|
||||
}
|
||||
ch <- true
|
||||
}()
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
panic("must nil")
|
||||
}
|
||||
panic("error")
|
||||
}()
|
||||
runtime.Goexit()
|
||||
}()
|
||||
<-ch
|
||||
}
|
||||
1
compiler/cl/_testgo/goexit/out.ll
Normal file
1
compiler/cl/_testgo/goexit/out.ll
Normal file
@@ -0,0 +1 @@
|
||||
;
|
||||
Reference in New Issue
Block a user