aaronbee
The harder case to deal with is a "push iterator", which are often much simpler to implement, but less flexible to use. See https://github.com/golang/go/discussions/56413
The OP is about converting a push iterator into a pull iterator efficiently by using coroutines. This provides the best of both worlds, simple iterator implementation and flexible use by its caller.
What’s holding it back currently is coming up with a way to do incremental rehash, which Go’s current map provides.
Below is what might be what they have meant. This code snippet is racy because an unsafe read of myResults is done to pass it to the goroutine and then that version of myResults is passed to safeAppend:
func ProcessAll(uuids []string) {
var myResults []string
var mutex sync.Mutex
safeAppend := func(results []string, res string) {
mutex.Lock()
myResults = append(myResults, res)
mutex.Unlock()
}
for _, uuid := range uuids {
go func(id string, results []string) {
res := Foo(id)
safeAppend(myResults, id)
}(uuid, myResults) # <<< unsafe read of myResults
}
}
EDIT: Formatting and clarityHere it is mentioned in go1.13 release notes: https://golang.org/doc/go1.13#compiler
And GitHub says the commit is present in go1.13: https://github.com/golang/go/commit/996a687ebbf81b26f81b41b8...
[1] https://www.coolearth.org/ [2] https://www.givingwhatwecan.org/charity/cool-earth/
Channels are good in other scenarios.
Report: Robots, other advances will cost humans 5.1M jobs by 2020
Google buys patents before they become weapons
Arq Backs Up to Google Cloud Storage Nearline
Bitcoin pool GHash.io commits to 40% hashrate limit after its 51% breach
With hard-links the underlying data is not deleted until all hard-links are deleted, so you can delete any individual backup directory without losing data in any other backup directory.
A soft-link is like a pointer in C whereas a hard-link is like a C++ shared_ptr, ie. reference counted.
[0] http://www.scala-lang.org/api/current/index.html#scala.util.... [1] http://www.scala-lang.org/api/current/index.html#scala.util....
One part of the pipeline checks if the destination MAC matches the switch's MAC. If it does then the packet is routed and the ASIC will read the destination IP address from the packet. The dest IP is looked up in the routing table to figure out which port the next hop lives on and what it's MAC address is. If the destination MAC is for another host, then the MAC table is checked to see what port to send the mac.
Modern ASICs are designed to handle both cases very quickly.