Skip to content

Commit

Permalink
Add more descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
poorna2152 committed Apr 10, 2024
1 parent f0a210d commit 35cedfa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 5 additions & 4 deletions examples/conditional-send/conditional_send.bal
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ public function main() {
}

worker w2 returns int|error:NoMessage {
// The corresponding send action here is conditionally executed.
// Thus, there is a possibility that it may not get executed.
// Therefore, the `error:NoMessage` type is included to handle such cases.
// The send action corresponding to this receive action is conditionally executed.
// Thus, there is a possibility that the send action may not get executed.
// Therefore, the static type of the receive includes the `error:NoMessage` type
// indicating the absence of a message in such cases.
int|error:NoMessage a = <- w1;
return a;
}
Expand All @@ -27,7 +28,7 @@ public function main() {
}

worker w4 returns int|error:NoMessage {
// The send action is used in two instances within worker `w3`.
// Two different conditional send actions exists within the worker `w3`.
// Therefore, an alternate receive action can be used to receive them.
int|error:NoMessage d = <- w3 | w3;
return d;
Expand Down
4 changes: 3 additions & 1 deletion examples/conditional-send/conditional_send.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Conditional send

The send action in workers can be used within a conditional context, allowing for more flexible and dynamic inter-worker communication based on specific conditions.
The send action in workers can be used in a conditional context, allowing for more flexible and dynamic inter-worker communication based on specific conditions. The receiver-side in a conditional send might not always receive a message. Thus to handle such scenarios, the static type of the receiver variable include the `error:NoMessage` type.



::: code conditional_send.bal :::

Expand Down

0 comments on commit 35cedfa

Please sign in to comment.