Commit b1c6e28a authored by Dominik Charousset's avatar Dominik Charousset

use sync_send in hello world example

parent 7373aef2
......@@ -9,26 +9,23 @@ void mirror() {
become (
// invoke this lambda expression if we receive a string
on_arg_match >> [](const std::string& what) {
// prints "Hello World!" via aout (thread-safe wrapper for cout)
// prints "Hello World!" via aout (thread-safe cout wrapper)
aout << what << std::endl;
// replies "!dlroW olleH"
reply(std::string(what.rbegin(), what.rend()));
// terminates this actor
// terminates this actor (become otherwise 'loops' forever)
self->quit();
}
);
}
void hello_world(const actor_ptr& buddy) {
// send "Hello World!" to our buddy
send(buddy, "Hello World!");
// wait for messages
become (
// send "Hello World!" to our buddy ...
sync_send(buddy, "Hello World!").then(
// ... and wait for a response
on_arg_match >> [](const std::string& what) {
// prints "!dlroW olleH"
aout << what << std::endl;
// terminate this actor
self->quit();
}
);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment