Commit 8db1e5c3 authored by Dominik Charousset's avatar Dominik Charousset

Initialize systems with argc+argv in examples

parent e9bc9c1f
...@@ -42,8 +42,8 @@ using calculator_bhvr = composed_behavior<adder_bhvr, multiplier_bhvr>; ...@@ -42,8 +42,8 @@ using calculator_bhvr = composed_behavior<adder_bhvr, multiplier_bhvr>;
} // namespace <anonymous> } // namespace <anonymous>
int main() { int main(int argc, char** argv) {
actor_system system; actor_system system{argc, argv};
auto f = make_function_view(system.spawn<calculator_bhvr>()); auto f = make_function_view(system.spawn<calculator_bhvr>());
cout << "10 + 20 = " << f(add_atom::value, 10, 20) << endl; cout << "10 + 20 = " << f(add_atom::value, 10, 20) << endl;
cout << "7 * 9 = " << f(multiply_atom::value, 7, 9) << endl; cout << "7 * 9 = " << f(multiply_atom::value, 7, 9) << endl;
......
...@@ -45,8 +45,8 @@ protected: ...@@ -45,8 +45,8 @@ protected:
} // namespace <anonymous> } // namespace <anonymous>
int main() { int main(int argc, char** argv) {
actor_system system; actor_system system{argc, argv};
auto f = make_function_view(system.spawn<dict_behavior>()); auto f = make_function_view(system.spawn<dict_behavior>());
f(put_atom::value, "CAF", "success"); f(put_atom::value, "CAF", "success");
cout << "CAF is the key to " << f(get_atom::value, "CAF") << endl; cout << "CAF is the key to " << f(get_atom::value, "CAF") << endl;
......
...@@ -329,7 +329,7 @@ std::atomic<bool> shutdown_flag{false}; ...@@ -329,7 +329,7 @@ std::atomic<bool> shutdown_flag{false};
} // namespace <anonymous> } // namespace <anonymous>
int main() { int main(int argc, char** argv) {
// random number setup // random number setup
// install signal handler // install signal handler
struct sigaction act; struct sigaction act;
...@@ -343,7 +343,7 @@ int main() { ...@@ -343,7 +343,7 @@ int main() {
set_sighandler(); set_sighandler();
// initialize CURL // initialize CURL
curl_global_init(CURL_GLOBAL_DEFAULT); curl_global_init(CURL_GLOBAL_DEFAULT);
actor_system system; actor_system system{argc, argv};
scoped_actor self{system}; scoped_actor self{system};
// spawn client and curl_master // spawn client and curl_master
auto master = self->spawn<detached>(curl_master); auto master = self->spawn<detached>(curl_master);
......
...@@ -81,8 +81,8 @@ void testee(event_based_actor* self, size_t remaining) { ...@@ -81,8 +81,8 @@ void testee(event_based_actor* self, size_t remaining) {
); );
} }
int main(int, char**) { int main(int argc, char** argv) {
actor_system_config cfg; actor_system_config cfg{argc, argv};
cfg.add_message_type<foo>("foo"); cfg.add_message_type<foo>("foo");
cfg.add_message_type<foo2>("foo2"); cfg.add_message_type<foo2>("foo2");
cfg.add_message_type<foo_pair>("foo_pair"); cfg.add_message_type<foo_pair>("foo_pair");
......
...@@ -61,8 +61,8 @@ behavior testee(event_based_actor* self) { ...@@ -61,8 +61,8 @@ behavior testee(event_based_actor* self) {
}; };
} }
int main(int, char**) { int main(int argc, char** argv) {
actor_system_config cfg; actor_system_config cfg{argc, argv};
cfg.add_message_type<foo>("foo"); cfg.add_message_type<foo>("foo");
actor_system system{cfg}; actor_system system{cfg};
anon_send(system.spawn(testee), foo{1, 2}); anon_send(system.spawn(testee), foo{1, 2});
......
...@@ -75,8 +75,8 @@ behavior testee(event_based_actor* self) { ...@@ -75,8 +75,8 @@ behavior testee(event_based_actor* self) {
}; };
} }
int main(int, char**) { int main(int argc, char** argv) {
actor_system_config cfg; actor_system_config cfg{argc, argv};
cfg.add_message_type<foo>("foo"); cfg.add_message_type<foo>("foo");
actor_system system{cfg}; actor_system system{cfg};
anon_send(system.spawn(testee), foo{1, 2}); anon_send(system.spawn(testee), foo{1, 2});
......
...@@ -191,8 +191,8 @@ private: ...@@ -191,8 +191,8 @@ private:
} // namespace <anonymous> } // namespace <anonymous>
int main(int, char**) { int main(int argc, char** argv) {
actor_system system; actor_system system{argc, argv};
scoped_actor self{system}; scoped_actor self{system};
// create five chopsticks // create five chopsticks
aout(self) << "chopstick ids are:"; aout(self) << "chopstick ids are:";
......
...@@ -36,8 +36,8 @@ behavior client(event_based_actor* self, const actor& serv) { ...@@ -36,8 +36,8 @@ behavior client(event_based_actor* self, const actor& serv) {
}; };
} }
int main() { int main(int argc, char** argv) {
actor_system system; actor_system system{argc, argv};
auto serv = system.spawn(server); auto serv = system.spawn(server);
auto worker = system.spawn(client, serv); auto worker = system.spawn(client, serv);
scoped_actor self{system}; scoped_actor self{system};
......
...@@ -127,8 +127,8 @@ void tester(scoped_actor& self, const Handle& hdl, int x, int y, Ts&&... xs) { ...@@ -127,8 +127,8 @@ void tester(scoped_actor& self, const Handle& hdl, int x, int y, Ts&&... xs) {
tester(self, std::forward<Ts>(xs)...); tester(self, std::forward<Ts>(xs)...);
} }
int main() { int main(int argc, char** argv) {
actor_system system; actor_system system{argc, argv};
auto a1 = system.spawn(blocking_calculator_fun); auto a1 = system.spawn(blocking_calculator_fun);
auto a2 = system.spawn(calculator_fun); auto a2 = system.spawn(calculator_fun);
auto a3 = system.spawn(typed_calculator_fun); auto a3 = system.spawn(typed_calculator_fun);
......
...@@ -44,8 +44,8 @@ behavior unchecked_cell(stateful_actor<cell_state>* self) { ...@@ -44,8 +44,8 @@ behavior unchecked_cell(stateful_actor<cell_state>* self) {
}; };
} }
int main() { int main(int argc, char** argv) {
actor_system system; actor_system system{argc, argv};
// create one cell for each implementation // create one cell for each implementation
auto cell1 = system.spawn(type_checked_cell); auto cell1 = system.spawn(type_checked_cell);
auto cell2 = system.spawn(unchecked_cell); auto cell2 = system.spawn(unchecked_cell);
......
...@@ -74,7 +74,7 @@ void dancing_kirby(event_based_actor* self) { ...@@ -74,7 +74,7 @@ void dancing_kirby(event_based_actor* self) {
); );
} }
int main() { int main(int argc, char** argv) {
actor_system system; actor_system system{argc, argv};
system.spawn(dancing_kirby); system.spawn(dancing_kirby);
} }
...@@ -36,7 +36,7 @@ calc::behavior_type actor_c() { ...@@ -36,7 +36,7 @@ calc::behavior_type actor_c() {
}; };
} }
int main() { int main(int argc, char** argv) {
actor_system system; actor_system system{argc, argv};
system.spawn(actor_a, system.spawn(actor_b, system.spawn(actor_c))); system.spawn(actor_a, system.spawn(actor_b, system.spawn(actor_c)));
} }
...@@ -47,11 +47,11 @@ divider::behavior_type divider_impl() { ...@@ -47,11 +47,11 @@ divider::behavior_type divider_impl() {
}; };
} }
int main() { int main(int argc, char** argv) {
auto renderer = [](uint8_t x, atom_value, const message&) { auto renderer = [](uint8_t x, atom_value, const message&) {
return "math_error" + deep_to_string_as_tuple(static_cast<math_error>(x)); return "math_error" + deep_to_string_as_tuple(static_cast<math_error>(x));
}; };
actor_system_config cfg; actor_system_config cfg{argc, argv};
cfg.add_error_category(atom("math"), renderer); cfg.add_error_category(atom("math"), renderer);
actor_system system{cfg}; actor_system system{cfg};
double x; double x;
......
...@@ -69,8 +69,8 @@ private: ...@@ -69,8 +69,8 @@ private:
behavior empty_; behavior empty_;
}; };
int main() { int main(int argc, char** argv) {
actor_system system; actor_system system{argc, argv};
auto st = system.spawn<fixed_stack>(5); auto st = system.spawn<fixed_stack>(5);
scoped_actor self{system}; scoped_actor self{system};
// fill stack // fill stack
......
...@@ -14,8 +14,8 @@ behavior foo(event_based_actor* self) { ...@@ -14,8 +14,8 @@ behavior foo(event_based_actor* self) {
}; };
} }
int main() { int main(int argc, char** argv) {
actor_system system; actor_system system{argc, argv};
scoped_actor self{system}; scoped_actor self{system};
aout(self) << "spawn foo" << endl; aout(self) << "spawn foo" << endl;
self->spawn(foo); self->spawn(foo);
......
...@@ -57,8 +57,8 @@ void blocking_testee(blocking_actor* self, vector<cell> cells) { ...@@ -57,8 +57,8 @@ void blocking_testee(blocking_actor* self, vector<cell> cells) {
}); });
} }
int main() { int main(int argc, char** argv) {
actor_system system; actor_system system{argc, argv};
vector<cell> cells; vector<cell> cells;
for (auto i = 0; i < 5; ++i) for (auto i = 0; i < 5; ++i)
cells.emplace_back(system.spawn(cell_impl, i * i)); cells.emplace_back(system.spawn(cell_impl, i * i));
......
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