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

2016-08-04 Thread pi
You mean something like this? func (b *RingBuf) ReadWait(min uint32, timeout time.Duration) bool { if min == 0 { min = 1 } if b.ReadAvail() >= min { return true } if timeout.Nanoseconds() == 0 { return false } const pollPeriod = 100 * t

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

2016-08-04 Thread pi
For several millions of goroutines - yes I think it matters. 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, sen

[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

Re: [go-nuts] Re: why treat int and []int differently here?

2016-07-16 Thread pi
Sorry my bad. Forget to add "in many cases" to last sentence. https://play.golang.org/p/7MtoscXiFo воскресенье, 17 июля 2016 г., 2:53:15 UTC+3 пользователь kortschak написал: > > On Sat, 2016-07-16 at 15:36 -0700, pi wrote: > > `type` is not `typedef` in Go. `type` int

[go-nuts] Re: why treat int and []int differently here?

2016-07-16 Thread pi
`type` is not `typedef` in Go. `type` introduces completely new type. Fortunately, Go can cast these types to base type silently, i.e. explicict cast int(valueOfTI) is unnecessary. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe

[go-nuts] Re: Did you try 1.7RC1 ?

2016-07-16 Thread pi
user 0m5.728s sys 0m0.572s go (go1.7rc1 linux/amd64, test is modified to use mmapped pools: https://github.com/pi/goal/blob/master/internal/tests/benchmarkgame-binarytrees/binarytrees.go): real 0m2.152s user 0m5.992s sys 0m0.328s -- You received this message because you are subscribed to the G

[go-nuts] Re: why the method set of *T is the superset of the method of T even if values of both *T and T can call both methods of *T and T?

2016-07-16 Thread pi
This is a syntatic sugar: v.Func() on non-pointer receiver is equivalent to (&v).Func() суббота, 16 июля 2016 г., 10:42:22 UTC+3 пользователь T L написал: > > is there any logic here? Or just a hard rule? > -- You received this message because you are subscribed to the Google Groups "golang-nu