//go:noinline func NewFoo(i int) *Foo { f := &Foo{a: rand.Intn(50)}
do((*uint)(unsafe.Pointer(&f.a)))
return f }
Ian Lance Taylor
unread,
Apr 25, 2020, 1:08:43 AM4/25/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to T L, golang-nuts
Finalizers are not guaranteed to run.
That said, I'm not sure why you are calling time.After. That doesn't
make finalizers any more likely to run. You'll probably see fairly
reliable results if you change that to call time.Sleep instead.
Ian
T L
unread,
Apr 25, 2020, 1:35:22 AM4/25/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
With time.Sleep, it always prints:
31 37 47 47 37 31
Why is each of the finalizers called twice?
Brian Candler
unread,
Apr 25, 2020, 1:53:28 AM4/25/20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to golang-nuts
On Saturday, 25 April 2020 06:35:22 UTC+1, T L wrote:
Why is each of the finalizers called twice?
Isn't it just printed once in main and once in finalizer?