alecrn
Go's concurrency model is inspired by Hoare's communicating sequential processes which kinda has the same idea: http://usingcsp.com/cspbook.pdf
For instance in this program:
func main() {
point1 := make(chan bool)
point2 := make(chan bool)
go func() {
point1 <- true
fmt.Println("hello")
point2 <- true
}()
<-point1
time.Sleep(3 * time.Second)
<-point2
}
An unbuffered channel read is always matched with a corresponding write. Let's call the point at which `point1 <- true` occurs and `<-point1` occurs T1 and the point at which `point2 <- true` occurs and `<-point2` occurs T2. fmt.Println("hello") and time.Sleep(3*time.Second) are both guaranteed to occur between T1 and T2. If we didn't have T2 there's no guarantee fmt.Println("hello") would run before the program exits.Maybe I'm wrong but this is my understanding of Hoare's and go's concurrency model.
func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
fmt.Println(runtime.NumCPU(), runtime.GOMAXPROCS(0))
started := make(chan bool)
go func() {
started <- true
for {
atomic.AddUint64(&a, uint64(1))
}
}()
<-started
for {
fmt.Println(atomic.LoadUint64(&a))
time.Sleep(time.Second)
}
}
Here we explicitly wait until the goroutine is started, so we know it's scheduled by the time our other loop runs. Here on my computer with go1.8 linux/amd64 it still optimizes out the while loop, which makes sense as nothing changed that would convince the optimizer the loop should remain given the compiler's current logic.If you add time.Sleep(time.Millisecond) to the goroutine loop or any other synchronization it works fine. I'm having trouble thinking of a real world example where you'd want an atomic operation going ham in a loop without any sort of time or synchronization. At the very least a channel indicating when the loop is done would cause the loop to compile.
One full rotation = tau
Half a rotation = 1/2 tau
1/10 a rotation = 1/10 tau
Something I've been curious about is if there are proxies that can convert protocols. So for instance, on your local machine, you could have a proxy that turns TCP connections on port 8000 into FASP connections to another machine. This would let you use an ordinary web browser over FASP.
You could even pipe the proxies, e.g., TCP -> FASP -> MinimaLT [1]. That way any program could have really fast data transfer over an encrypted tunnel.
Git is already a great tool with a workflow for handling incremental updates that I happen to be used to working with, so there was no need to reinvent the wheel.
Show HN: Push/fetch encrypted Git repositories like GitHub
[1] http://corte.si/%2Fposts/code/hilbert/portrait/index.html
http://pubs.opengroup.org/onlinepubs/7999959899/basedefs/std...