-
Notifications
You must be signed in to change notification settings - Fork 192
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
129bcb6
commit 89d4c8f
Showing
5 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import ballerina/io; | ||
import ballerina/lang.runtime; | ||
|
||
public function main() { | ||
worker w1 { | ||
2 -> w3; | ||
} | ||
|
||
worker w2 { | ||
runtime:sleep(2); | ||
3 -> w3; | ||
} | ||
|
||
worker w3 returns map<int> { | ||
// worker waits until both values are received. | ||
map<int> result = <- {w1, w2}; | ||
return result; | ||
} | ||
|
||
map<int> results = wait w3; | ||
io:println(results["w1"]); | ||
io:println(results["w2"]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# Multiple receive | ||
|
||
The multiple receive action allows receiving messages from multiple workers. | ||
|
||
::: code multiple_receive.bal ::: | ||
|
||
::: out multiple_receive.out ::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
description: This BBE demonstrates the multiple receive action. | ||
keywords: ballerina, ballerina by example, bbe, worker, multiple receive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
$ bal run multiple_receive.bal | ||
2 | ||
3 |