Skip to content

Commit

Permalink
Address review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
poorna2152 committed Apr 10, 2024
1 parent 15f0dbe commit 2ea5379
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions examples/alternate-receive/alternate_receive.bal
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function main() {
worker w4 returns error? {
int value = 10;
if value == 10 {
return error("Error in worker 1");
return error("Error in worker 4");
}
value -> w6;
}
Expand All @@ -32,16 +32,16 @@ public function main() {
}

worker w6 returns int|error? {
// Alternate receive action waits until a message that is not an error is received
// when error is not an expected static type. Since `w4` returns an error it
// waits further and sets the value that is received from `w5`.
// Alternate receive action waits until a message that is not an error is received.
// Since `w4` returns an error, it waits further and
// sets the value that is received from `w5`.
int a = check <- w4 | w5;
return a;
}

int valueW3 = wait w3;
io:println(valueW3);
int w3Result = wait w3;
io:println(w3Result);

int|error? valueW6 = wait w6;
io:println(valueW6);
int|error? w6Result = wait w6;
io:println(w6Result);
}
2 changes: 1 addition & 1 deletion examples/alternate-receive/alternate_receive.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Alternate receive

The alternate receive action can be used to receive values from several workers.
The alternate receive action can be used receive values from several workers. It waits until either a non-error message, a panic termination status on a closed channel, or closure of all channels. Alternate receive actions sets the first non-error value it encounters as the result.

::: code alternate_receive.bal :::

Expand Down
2 changes: 1 addition & 1 deletion examples/alternate-receive/alternate_receive.metatags
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
description: This BBE demonstrates the alternate receive action
description: This BBE demonstrates the use of the alternate receive action in inter-worker communication
keywords: ballerina, ballerina by example, bbe, worker, alternate receive
14 changes: 7 additions & 7 deletions examples/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -1419,13 +1419,6 @@
"disableVerificationReason": "Includes varying output",
"isLearnByExample": true
},
{
"name": "Alternate receive",
"url": "alternate-receive",
"verifyBuild": true,
"verifyOutput": true,
"isLearnByExample": true
},
{
"name": "Multiple wait",
"url": "multiple-wait",
Expand Down Expand Up @@ -1474,6 +1467,13 @@
"verifyBuild": true,
"verifyOutput": true,
"isLearnByExample": true
},
{
"name": "Alternate receive",
"url": "alternate-receive",
"verifyBuild": true,
"verifyOutput": true,
"isLearnByExample": true
}
]
},
Expand Down

0 comments on commit 2ea5379

Please sign in to comment.