diff --git a/concurrency/confinement/adhoc/main.go b/concurrency/confinement/adhoc/main.go new file mode 100644 index 0000000..8bb1ab6 --- /dev/null +++ b/concurrency/confinement/adhoc/main.go @@ -0,0 +1,27 @@ +package main + +import "fmt" + +// Confinement is the simple yet powerful idea of ensuring information is only ever +// available from one concurrent process. + +// When this is achieved, a concurrent program +//is implicitly safe and no synchronization is needed. + +// Ad hoc confinement is when you achieve confinement through a convention— +// whether it be set by the languages community, the group you work within, or the +// codebase you work within +func main() { + data := make([]int, 4) + loopData := func(handleData chan<- int) { + defer close(handleData) + for i := range data { + handleData <- data[i] + } + } + handleData := make(chan int) + go loopData(handleData) + for num := range handleData { + fmt.Println(num) + } +} diff --git a/concurrency/iterator_error_handling/main.go b/concurrency/iterator_error_handling/main.go index 0057b06..32fc812 100644 --- a/concurrency/iterator_error_handling/main.go +++ b/concurrency/iterator_error_handling/main.go @@ -107,6 +107,8 @@ func v2() { "https://insights.stackoverflow.com/survey/2017", "https://hackernoon.com/top-10-python-web-frameworks-to-learn-in-2018-b2ebab969d1a", "https://blog.kowalczyk.info/article/1Bkr/3-ways-to-iterate-in-go.html", + "A", + "B", } for result := range checkStatus(done, urls...) { if result.Error != nil {