You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There seems to be a small delay incurred when Timer starts. Note the "sync" workaround in notBroken. This behavior was noticed on go1.2.1 linux/amd64 and is repeatable on play.golang.org and go1.4.1 linux/amd64.
The following program outputs:
This is the undesired behavior.
This is the desired select.
package main
import"time"funcmain() {
broken()
println()
notBroken()
}
funcbroken() {
t:=time.NewTimer(0*time.Second)
select {
case_=<-t.C:
println("This is the desired select.")
default:
println("This is the undesired behavior.")
}
}
funcnotBroken() {
t:=time.NewTimer(0*time.Second)
sync:=time.NewTimer(0*time.Second)
_=<-sync.Cselect {
case_=<-t.C:
println("This is the desired select.")
default:
println("This does not get selected.")
}
}
The text was updated successfully, but these errors were encountered:
binary132
changed the title
time.Timer with zero Duration seems to have a moment of delay
time: Timer with zero Duration seems to have a moment of delay
Mar 10, 2015
http://play.golang.org/p/9saBM6ph-9
There seems to be a small delay incurred when Timer starts. Note the "
sync
" workaround innotBroken
. This behavior was noticed ongo1.2.1 linux/amd64
and is repeatable on play.golang.org andgo1.4.1 linux/amd64
.The following program outputs:
The text was updated successfully, but these errors were encountered: