documentation
documentation copied to clipboard
[ Documentation request ] workflow.Go() / Multi-threading documentation
Brief description
It is sometimes desirable to submit multiple activities in parallel, or children workflows, and then accumulate the result when it's available. However, in "normal" programming, one would need to lock around some shared data structure (an array) to avoid race conditions that could occur when multiple asynchronous operations try to modify the data structure.
As discussed in the forum, the following example https://github.com/temporalio/samples-go/blob/2e68e3fb1b3bb302f4e64108a4037902b24539b4/pso/swarm.go#L38 shows that it is not required in Temporal, and it is discussed here in Stackoverflow.
https://stackoverflow.com/questions/71356668/how-does-multi-threading-works-in-cadence-temporal-workflow/71356669#71356669
Your recommended content
We probably should document that there's no need to use mutexes in this case, and explain that although workflow.Go() is effectively async, there is a control in place that ensures only one thread can access at the time.
It is probably also desirable to have simple examples (in samples-go) for example of multiple activities submission in parallel, and maybe children workflow too