diff options
author | Russ Cox <rsc@golang.org> | 2020-03-09 23:54:35 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2020-03-17 20:58:37 +0000 |
commit | af5018f64e406aaa646dae066f28de57321ea5ce (patch) | |
tree | 8db7b1f049d83d215fa9abf68851efce7b5ccadb /content/share-memory-by-communicating.article | |
parent | 86e424fac66fa90ddcb7e8d7febd4c2b07d7c59e (diff) |
content: convert to Markdown-enabled present inputs
Converted blog to Markdown-enabled present (CL 222846)
using present2md (CL 222847).
For golang/go#33955.
Change-Id: Ib39fa1ddd9a46f9c7a62a2ca7b96e117635553e8
Reviewed-on: https://go-review.googlesource.com/c/blog/+/222848
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Diffstat (limited to 'content/share-memory-by-communicating.article')
-rw-r--r-- | content/share-memory-by-communicating.article | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/content/share-memory-by-communicating.article b/content/share-memory-by-communicating.article index 01c7426..12bff79 100644 --- a/content/share-memory-by-communicating.article +++ b/content/share-memory-by-communicating.article @@ -1,10 +1,11 @@ -Share Memory By Communicating +# Share Memory By Communicating 13 Jul 2010 Tags: concurrency, technical +Summary: Traditional threading models (commonly used when writing Java, C++, and Python programs, for example) require the programmer to communicate between threads using shared memory. Typically, shared data structures are protected by locks, and threads will contend over those locks to access the data. In some cases, this is made easier by the use of thread-safe data structures such as Python's Queue. Andrew Gerrand -* Introduction +## Traditional threading models (commonly used when writing Java, C++, and Python programs, for example) require the programmer to communicate @@ -16,15 +17,15 @@ such as Python's Queue. Go's concurrency primitives - goroutines and channels - provide an elegant and distinct means of structuring concurrent software. -(These concepts have an [[https://swtch.com/~rsc/thread/][interesting history]] that begins with C. -A. R. Hoare's [[http://www.usingcsp.com/][Communicating Sequential Processes]].) +(These concepts have an [interesting history](https://swtch.com/~rsc/thread/) that begins with C. +A. R. Hoare's [Communicating Sequential Processes](http://www.usingcsp.com/).) Instead of explicitly using locks to mediate access to shared data, Go encourages the use of channels to pass references to data between goroutines. This approach ensures that only one goroutine has access to the data at a given time. -The concept is summarized in the document [[https://golang.org/doc/effective_go.html][Effective Go]] +The concept is summarized in the document [Effective Go](https://golang.org/doc/effective_go.html) (a must-read for any Go programmer): -_Do_not_communicate_by_sharing_memory;_instead,_share_memory_by_communicating._ +_Do not communicate by sharing memory; instead, share memory by communicating._ Consider a program that polls a list of URLs. In a traditional threading environment, one might structure its data like so: @@ -102,4 +103,4 @@ This should give you an inkling as to the power of these simple language feature There are many omissions from the above code snippets. For a walkthrough of a complete, idiomatic Go program that uses these ideas, -see the Codewalk [[https://golang.org/doc/codewalk/sharemem/][_Share_Memory_By_Communicating_]]. +see the Codewalk [_Share Memory By Communicating_](https://golang.org/doc/codewalk/sharemem/). |