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
const numCPU = 4 // number of CPU cores
func (v Vector) DoAll(u Vector) {
c := make(chan int, numCPU) // Buffering optional but sensible.
for i := 0; i < numCPU; i++ {
go v.DoSome(i*len(v)/numCPU, (i+1)*len(v)/numCPU, u, c)
}
// Drain the channel.
for i := 0; i < numCPU; i++ {
<-c // wait for one task to complete
}
// All done.
}
If len(v) is 10 doSome will receive
i = 0, n = 2
i = 2, n = 5
i = 5, n = 7
i = 7, n = 10
And because in doSome we have i < nwe drop 10.
The text was updated successfully, but these errors were encountered:
Here.
If
len(v)
is 10doSome
will receivei = 0, n = 2
i = 2, n = 5
i = 5, n = 7
i = 7, n = 10
And because in
doSome
we havei < n
we drop 10.The text was updated successfully, but these errors were encountered: