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() { ...@@ -9,26 +9,23 @@ void mirror() {
become ( become (
// invoke this lambda expression if we receive a string // invoke this lambda expression if we receive a string
on_arg_match >> [](const std::string& what) { 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; aout << what << std::endl;
// replies "!dlroW olleH" // replies "!dlroW olleH"
reply(std::string(what.rbegin(), what.rend())); reply(std::string(what.rbegin(), what.rend()));
// terminates this actor // terminates this actor (become otherwise 'loops' forever)
self->quit(); self->quit();
} }
); );
} }
void hello_world(const actor_ptr& buddy) { void hello_world(const actor_ptr& buddy) {
// send "Hello World!" to our buddy // send "Hello World!" to our buddy ...
send(buddy, "Hello World!"); sync_send(buddy, "Hello World!").then(
// wait for messages // ... and wait for a response
become (
on_arg_match >> [](const std::string& what) { on_arg_match >> [](const std::string& what) {
// prints "!dlroW olleH" // prints "!dlroW olleH"
aout << what << std::endl; 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