import ballerina/io;
public function main() {
worker A {
// Use `-> W` to send a message to worker `W`.
1 -> B;
2 -> C;
}
worker B {
// Use `<- W` to receive a message from worker `W`.
int x1 = <- A;
// Use `function` to refer to the function's default worker.
x1 -> function;
}
worker C {
int x2 = <- A;
x2 -> function;
}
int y1 = <- B;
int y2 = <- C;
io:println(y1 + y2);
}
Inter-worker message passingUse |
import ballerina/io;
public function main() {
worker A {
1 -> B;
2 -> C;
Use -> W
to send a message to worker W
.
}
worker B {
int x1 = <- A;
Use <- W
to receive a message from worker W
.
x1 -> function;
Use function
to refer to the function’s default worker.
}
worker C {
int x2 = <- A;
x2 -> function;
}
int y1 = <- B;
int y2 = <- C;
io:println(y1 + y2);
}
bal run inter_worker_message_passing.bal
3