16
16
- [ (S) Garbage Collection] ( #s-garbage-collection )
17
17
- [ (D) Compilation] ( #d-compilation )
18
18
- [ Concurrency & Parallelism] ( #concurrency--parallelism )
19
- - [ Overview (D)] ( #overview-d )
20
- - [ Async vs Sync APIs (D) ] ( #async-vs-sync-apis-d )
21
- - [ Sequential and Concurrent Patterns (D) ] ( #sequential-and-concurrent-patterns-d )
19
+ - [ (D) Overview ] ( #d-overview )
20
+ - [ (D) Async vs Sync APIs] ( #d- async-vs-sync-apis )
21
+ - [ (D) Sequential and Concurrent Patterns] ( #d- sequential-and-concurrent-patterns )
22
22
- [ Modules / Packages] ( #modules--packages )
23
23
- [ Spec & Practice] ( #spec--practice )
24
24
- [ Management] ( #management )
@@ -105,7 +105,7 @@ Go is compiled. Javascript is not, though some Javascript runtimes use JIT compi
105
105
106
106
# Concurrency & Parallelism
107
107
108
- ## Overview (D)
108
+ ## (D) Overview
109
109
110
110
** JS**
111
111
@@ -126,7 +126,7 @@ More on this subject:
126
126
- [ Advanced Go Concurrency Patterns] ( https://talks.golang.org/2013/advconc.slide#1 )
127
127
128
128
129
- ## Async vs Sync APIs (D)
129
+ ## (D) Async vs Sync APIs
130
130
** JS**
131
131
132
132
JS promotes writing async APIs, since sync APIs always block the caller, e.g:
@@ -155,21 +155,21 @@ func fetchA() fetchResult {
155
155
return fetchResult{" A data" , nil }
156
156
}
157
157
```
158
- If the caller wants to be blocked, then he can just the function
158
+ If the caller wants to be blocked, then he can just call the function
159
159
``` Go
160
160
a := fetchA ()
161
161
```
162
- If the caller does not want to be blocked, then he could run the function inside a goroutine:
162
+ If the caller does not want to be blocked, then he could call the function inside a goroutine:
163
163
``` Go
164
164
aChan := make (chan fetchResult, 0 )
165
165
go func (c chan fetchResult) {
166
166
c <- fetchA ()
167
167
}(aChan)
168
168
```
169
169
170
- ## Sequential and Concurrent Patterns (D)
170
+ ## (D) Sequential and Concurrent Patterns
171
171
172
- ** Go **
172
+ ** JS **
173
173
174
174
Even without parallelism, we can structure Javascript code in both sequential and concurrent flows.
175
175
For the following exmaples, let’s assume ` fetchA() ` , ` fetchB() ` and ` fetchC() ` are all async functions returning a promise.
0 commit comments