[go-nuts] How to wait for specified amount of time in a loop without timer overhead

2016-08-04 Thread Dave Cheney
If you're going to sleep, does it matter if time.Sleep has a cost? -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For m

[go-nuts] How to wait for specified amount of time in a loop without timer overhead

2016-08-04 Thread pi
Hi. I'd like to write function with spin-loop like this: func readWait(timeout time.Duration) bool { deadline := Nanotime() + timeout.Nanoseconds() for { if readAvail() { return true } if Nanotime() >= deadline { return false } runtime.Goshed() } } But runtime.nanotime() is not exported. How can