
This costs a bit in code size, but should be more flexible for the future to implement recover() and running deferred functions while panicking.
17 строки
236 Б
Go
17 строки
236 Б
Go
package runtime
|
|
|
|
import "unsafe"
|
|
|
|
type deferContext unsafe.Pointer
|
|
|
|
type _defer struct {
|
|
callback func(*_defer)
|
|
next *_defer
|
|
}
|
|
|
|
func rundefers(stack *_defer) {
|
|
for stack != nil {
|
|
stack.callback(stack)
|
|
stack = stack.next
|
|
}
|
|
}
|