Course of Raku / Functional, concurrent, reactive, and web programming / Concurrent programming / Promises / Exercises / Await many
Solution: Await many
Here is a possible solution to the task.
Code
my @jobs = (start { 2 }), (start { 3 }), (start { 4 });
say [*] await @jobs;🦋 You can find the source code in the file await-many.raku.
Output
24Comments
The three promises run concurrently;
await @jobswaits for all of them and returns their results in order,(2, 3, 4).The reduce metaoperator
[*]multiplies them, giving24.
Course navigation
← Await many | Kept or broken →