Skip to content

Instantly share code, notes, and snippets.

Avatar

Richard Fliam rfliam

  • Mediakind
  • Denver, CO
View GitHub Profile
@rfliam
rfliam / NaturalNumbers.go
Last active May 29, 2019
Constructing the Natural Numbers Using Go2 Contract
View NaturalNumbers.go
// A natural number has a successor, and is a successor of zero (the peano axiomatization)
contract Natural(x T) {
var v = Succ(x)()
var b bool = IsZero(x)
}
type Nat(type T Natural) struct {}
type Z Nat(struct{})
View Do You Like DAGs?.md

Do You Like DAGs?

Understanding Communicating Sequential Processes, (Directed) Acyclic Graphs, and the select Operator

After much discussion with Roger Peppe (@rogpeppe) following my speech at gophercon, I thought it might be best to clarify my thoughts on and understanding of how to avoid deadlocks in go (using CSP, DAG's and select).

Damian Gryski (@dgryski) provided a link to a nice summary of the conditions necessary for a deadlock:

  1. mutual exclusion
  2. hold and wait or partial allocation
  3. no pre-emption
  4. resource waiting or circular wait