Skip to content
Browse files

use sync_send in hello world example

  • Loading branch information...
1 parent 7373aef commit b1c6e28ae464a313712ba931940043a00413bf9a @Neverlord Neverlord committed
Showing with 5 additions and 8 deletions.
  1. +5 −8 examples/hello_world.cpp
View
13 examples/hello_world.cpp
@@ -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();
}
);
}

0 comments on commit b1c6e28

Please sign in to comment.
Something went wrong with that request. Please try again.