@@ -76,16 +76,13 @@ trivial and it requires a lot of boilerplate that makes the important parts of
7676the code more difficult to read, so ` conc ` does this for you.
7777
7878<table >
79- <tr>
80- <th>
81- `stdlib`
82- </th>
83- <th>
84- `conc`
85- </th>
86- </tr>
87- <tr>
88- <td>
79+ <tr >
80+ <th ><code >stdlib</code ></th >
81+ <th ><code >conc</code ></th >
82+ </tr >
83+ <tr >
84+ <td >
85+
8986``` go
9087type caughtPanicError struct {
9188 val any
@@ -117,17 +114,18 @@ func spawn() {
117114 }
118115}
119116```
120- </td>
121- <td>
117+ </td >
118+ <td >
119+
122120``` go
123121func spawn () {
124122 var wg conc.WaitGroup
125123 wg.Go (doSomethingThatMightPanic)
126124 wg.Wait ()
127125}
128126```
129- </td>
130- </tr>
127+ </td >
128+ </tr >
131129</table >
132130
133131## Goal #3 : Make concurrent code easier to read
@@ -152,16 +150,13 @@ what kind of complexity that would add, check out the "Goal #2" header above.
152150Spawn a set of goroutines and waiting for them to finish:
153151
154152<table >
155- <tr>
156- <th>
157- `stdlib`
158- </th>
159- <th>
160- `conc`
161- </th>
162- </tr>
163- <tr>
164- <td>
153+ <tr >
154+ <th ><code >stdlib</code ></th >
155+ <th ><code >conc</code ></th >
156+ </tr >
157+ <tr >
158+ <td >
159+
165160``` go
166161func main () {
167162 var wg sync.WaitGroup
@@ -176,8 +171,9 @@ func main() {
176171 wg.Wait ()
177172}
178173```
179- </td>
180- <td>
174+ </td >
175+ <td >
176+
181177``` go
182178func main () {
183179 var wg conc.WaitGroup
@@ -187,23 +183,20 @@ func main() {
187183 wg.Wait ()
188184}
189185```
190- </td>
191- </tr>
186+ </td >
187+ </tr >
192188</table >
193189
194190Process each element of a stream in a static pool of goroutines:
195191
196192<table >
197- <tr>
198- <th>
199- `stdlib`
200- </th>
201- <th>
202- `conc`
203- </th>
204- </tr>
205- <tr>
206- <td>
193+ <tr >
194+ <th ><code >stdlib</code ></th >
195+ <th ><code >conc</code ></th >
196+ </tr >
197+ <tr >
198+ <td >
199+
207200``` go
208201func process (stream chan int ) {
209202 var wg sync.WaitGroup
@@ -219,8 +212,9 @@ func process(stream chan int) {
219212 wg.Wait ()
220213}
221214```
222- </td>
223- <td>
215+ </td >
216+ <td >
217+
224218``` go
225219func process (stream chan int ) {
226220 p := pool.New ().WithMaxGoroutines (10 )
@@ -232,23 +226,20 @@ func process(stream chan int) {
232226 p.Wait ()
233227}
234228```
235- </td>
236- </tr>
229+ </td >
230+ </tr >
237231</table >
238232
239233Process each element of a slice in a static pool of goroutines:
240234
241235<table >
242- <tr>
243- <th>
244- `stdlib`
245- </th>
246- <th>
247- `conc`
248- </th>
249- </tr>
250- <tr>
251- <td>
236+ <tr >
237+ <th ><code >stdlib</code ></th >
238+ <th ><code >conc</code ></th >
239+ </tr >
240+ <tr >
241+ <td >
242+
252243``` go
253244func main () {
254245 values := []int {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 }
@@ -273,32 +264,30 @@ func main() {
273264 wg.Wait ()
274265}
275266```
276- </td>
277- <td>
267+ </td >
268+ <td >
269+
278270``` go
279271func main () {
280272 values := []int {1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 }
281273 iter.ForEach (values, handle)
282274}
283275```
284- </td>
285- </tr>
276+ </td >
277+ </tr >
286278</table >
287279
288280Process an ordered stream concurrently:
289281
290282
291283<table >
292- <tr>
293- <th>
294- `stdlib`
295- </th>
296- <th>
297- `conc`
298- </th>
299- </tr>
300- <tr>
301- <td>
284+ <tr >
285+ <th ><code >stdlib</code ></th >
286+ <th ><code >conc</code ></th >
287+ </tr >
288+ <tr >
289+ <td >
290+
302291``` go
303292func mapStream (input chan int , output chan int , f func (int ) int ) {
304293 tasks := make (chan func ())
@@ -342,8 +331,9 @@ func mapStream(input chan int, output chan int, f func(int) int) {
342331 readerWg.Wait ()
343332}
344333```
345- </td>
346- <td>
334+ </td >
335+ <td >
336+
347337``` go
348338func mapStream (input chan int , output chan int , f func (int ) int ) {
349339 s := stream.New ().WithMaxGoroutines (10 )
@@ -357,6 +347,6 @@ func mapStream(input chan int, output chan int, f func(int) int) {
357347 s.Wait ()
358348}
359349```
360- </td>
361- </tr>
350+ </td >
351+ </tr >
362352</table >
0 commit comments