- Tests code generation using ccg (reusee/ccg).
- Encapsulates a concurrency pattern.
GoAndWait wraps a common concurrency pattern into a generic function:
- The items of a list shall be processed concurrently
- The main routine must wait until all items have been processed
Usually this is done by setting up a back channel, spawning n goroutines for n list items, and then reading n items from the back channel. Each goroutine must send an item to the back channel when done.
GoAndWait encapsulates this pattern, thus reducing code repetition.
Generate code from this template by running:
ccg -f concurrent -t T=int -o concurrent.go