Commit d67d10b2 authored by Dominik Charousset's avatar Dominik Charousset

more consistent coding style

parent 7bc8b9ce
...@@ -41,22 +41,21 @@ using namespace std; ...@@ -41,22 +41,21 @@ using namespace std;
using namespace cppa; using namespace cppa;
struct testee : sb_actor<testee> { struct testee : sb_actor<testee> {
actor_ptr parent;
behavior init_state; behavior init_state;
testee(const actor_ptr& pptr) : parent(pptr) { testee(const actor_ptr& parent) {
init_state = ( init_state = (
on(atom("spread"), unsigned(0)) >> [=]() { on(atom("spread"), (uint32_t) 0) >> [=]() {
send(parent, atom("result"), (uint32_t) 1); send(parent, atom("result"), (uint32_t) 1);
quit(); quit();
}, },
on(atom("spread"), arg_match) >> [=](unsigned x) { on(atom("spread"), arg_match) >> [=](uint32_t x) {
any_tuple msg = make_cow_tuple(atom("spread"), x - 1); any_tuple msg = make_cow_tuple(atom("spread"), x - 1);
spawn<testee>(this) << msg; spawn<testee>(this) << msg;
spawn<testee>(this) << msg; spawn<testee>(this) << msg;
become ( become (
on<atom("result"), uint32_t>() >> [=](uint32_t r1) { on(atom("result"), arg_match) >> [=](uint32_t r1) {
become ( become (
on<atom("result"), uint32_t>() >> [=](uint32_t r2) { on(atom("result"), arg_match) >> [=](uint32_t r2) {
send(parent, atom("result"), r1 + r2); send(parent, atom("result"), r1 + r2);
quit(); quit();
} }
...@@ -70,17 +69,17 @@ struct testee : sb_actor<testee> { ...@@ -70,17 +69,17 @@ struct testee : sb_actor<testee> {
void stacked_testee(actor_ptr parent) { void stacked_testee(actor_ptr parent) {
receive ( receive (
on(atom("spread"), unsigned(0)) >> [&]() { on(atom("spread"), (uint32_t) 0) >> [&]() {
send(parent, atom("result"), (uint32_t) 1); send(parent, atom("result"), (uint32_t) 1);
}, },
on<atom("spread"), unsigned>() >> [&](unsigned x) { on(atom("spread"), arg_match) >> [&](uint32_t x) {
any_tuple msg = make_cow_tuple(atom("spread"), x-1); any_tuple msg = make_cow_tuple(atom("spread"), x - 1);
spawn(stacked_testee, self) << msg; spawn(stacked_testee, self) << msg;
spawn(stacked_testee, self) << msg; spawn(stacked_testee, self) << msg;
receive ( receive (
on<atom("result"), uint32_t>() >> [&](uint32_t v1) { on(atom("result"), arg_match) >> [&](uint32_t v1) {
receive ( receive (
on<atom("result"),uint32_t>() >> [&](uint32_t v2) { on(atom("result"), arg_match) >> [&](uint32_t v2) {
send(parent, atom("result"), v1 + v2); send(parent, atom("result"), v1 + v2);
} }
); );
...@@ -99,10 +98,10 @@ void usage() { ...@@ -99,10 +98,10 @@ void usage() {
int main(int argc, char** argv) { int main(int argc, char** argv) {
vector<string> args(argv + 1, argv + argc); vector<string> args(argv + 1, argv + argc);
match (args) ( match (args) (
on("stacked", spro<unsigned>) >> [](unsigned num) { on("stacked", spro<uint32_t>) >> [](uint32_t num) {
send(spawn(stacked_testee, self), atom("spread"), num); send(spawn(stacked_testee, self), atom("spread"), num);
}, },
on("event-based", spro<unsigned>) >> [](unsigned num) { on("event-based", spro<uint32_t>) >> [](uint32_t num) {
send(spawn<testee>(self), atom("spread"), num); send(spawn<testee>(self), atom("spread"), num);
}, },
others() >> usage others() >> usage
......
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