Skip to content

Commit f60162f

Browse files
authored
Enhance concurrency documentation with child workflows
Added section on child workflows and parallel execution.
1 parent 00c6b36 commit f60162f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

docs/features/concurrency.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,19 @@ class MyWorkflow extends Workflow
8181
![workflow](https://mermaid.ink/img/pako:eNp9kctugzAQRX8lmjUBbPOyK1WqlC6zalcVGwcbsAQYwRCVRvx7DZUS0UW88txzNc8bFFZpEFANsq8Pn6eXvDsczvNbgeZqcCbH4-sjos9g9AzGe0h3kO0h28FkD6NnMP4PwYNWD600yo14W805YK1bnYNwX6VLOTWYQ94tziontB9zV4DAYdIeTL2SqE9GuuW0IErZjHf1XRm0w11srFTahTfAud_2aUZ0KQvblaZa9WlonFwj9qMIghX7lcF6uviFbYPRqFoOWF95EiQ0ySRlOkmZjBlTxYXwrKQRKVUaEiphWTzoZfdl7aMrvfVz_jvmdtPNs1b-BhH7PORxxBNGGM1SHnkwg0iZHxFOU-YKxoxy6vL-bEmJH26POBxymvFk-QWh37PQ?type=png)
8282

8383
Activity 1 will execute and complete before any other activities start. Activities 2 and 3 will execute in series, waiting for each to complete one after another before continuing. At the same time, activities 4 and 5 will execute together in parallel and only when they all complete will execution continue. Finally, activity 6 executes last after all others have completed.
84+
85+
## Child Workflows in Parallel
86+
87+
You can pass child workflows to `ActivityStub::all()` along with with other activities (but we also provide `ChildWorkflowStub::all()` if you prefer). Both of these are just thin wrappers for React Promise's `all()`. It works the same way as parallel activity execution, but for child workflows. It allows you to fan out multiple child workflows and wait for all of them to complete together.
88+
89+
```php
90+
use Workflow\ChildWorkflowStub;
91+
92+
$results = yield ChildWorkflowStub::all([
93+
ChildWorkflowStub::make(ChildA::class),
94+
ChildWorkflowStub::make(ChildB::class),
95+
ChildWorkflowStub::make(ChildC::class),
96+
]);
97+
```
98+
99+
This makes it easy to build hierarchical parallelism into your workflows.

0 commit comments

Comments
 (0)