Commit e0b19e2c authored by Dominik Charousset's avatar Dominik Charousset

maintenance

parent 9eb9765a
...@@ -37,11 +37,7 @@ ...@@ -37,11 +37,7 @@
#include "cppa/cppa.hpp" #include "cppa/cppa.hpp"
#include "cppa/sb_actor.hpp" #include "cppa/sb_actor.hpp"
using std::cout; using namespace std;
using std::cerr;
using std::endl;
using std::uint32_t;
using namespace cppa; using namespace cppa;
struct testee : sb_actor<testee> { struct testee : sb_actor<testee> {
...@@ -49,11 +45,11 @@ struct testee : sb_actor<testee> { ...@@ -49,11 +45,11 @@ struct testee : sb_actor<testee> {
behavior init_state; behavior init_state;
testee(const actor_ptr& pptr) : parent(pptr) { testee(const actor_ptr& pptr) : parent(pptr) {
init_state = ( init_state = (
on(atom("spread"), 0) >> [=]() { on(atom("spread"), unsigned(0)) >> [=]() {
send(parent, atom("result"), (uint32_t) 1); send(parent, atom("result"), (uint32_t) 1);
quit(); quit();
}, },
on<atom("spread"), int>() >> [=](int x) { on(atom("spread"), arg_match) >> [=](unsigned 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;
...@@ -74,10 +70,10 @@ struct testee : sb_actor<testee> { ...@@ -74,10 +70,10 @@ struct testee : sb_actor<testee> {
void stacked_testee(actor_ptr parent) { void stacked_testee(actor_ptr parent) {
receive ( receive (
on(atom("spread"), 0) >> [&]() { on(atom("spread"), unsigned(0)) >> [&]() {
send(parent, atom("result"), (uint32_t) 1); send(parent, atom("result"), (uint32_t) 1);
}, },
on<atom("spread"), int>() >> [&](int x) { on<atom("spread"), unsigned>() >> [&](unsigned 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;
...@@ -101,33 +97,17 @@ void usage() { ...@@ -101,33 +97,17 @@ void usage() {
} }
int main(int argc, char** argv) { int main(int argc, char** argv) {
if (argc == 3) { vector<string> args(argv + 1, argv + argc);
int num = rd<int>(argv[2]); match (args) (
if (strcmp(argv[1], "stacked") == 0) { on("stacked", spro<unsigned>) >> [](unsigned num) {
send(spawn(stacked_testee, self), atom("spread"), num); send(spawn(stacked_testee, self), atom("spread"), num);
} },
else if (strcmp(argv[1], "event-based") == 0) { on("event-based", spro<unsigned>) >> [](unsigned num) {
send(spawn<testee>(self), atom("spread"), num); send(spawn<testee>(self), atom("spread"), num);
} },
else { others() >> usage
usage(); );
return 1; await_all_others_done();
} shutdown();
receive (
on<atom("result"),uint32_t>() >> [=](uint32_t value) {
//cout << "value = " << value << endl
// << "expected => 2^" << num << " = "
// << (1 << num) << endl;
if (value != (((uint32_t) 1) << num)) {
cerr << "ERROR: received wrong result!\n";
}
}
);
await_all_others_done();
}
else {
usage();
return 1;
}
return 0; return 0;
} }
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