void caf_main(actor_system& system) { // create one cell for each implementation auto cell1 = system.spawn(type_checked_cell); auto cell2 = system.spawn(unchecked_cell); auto f = make_function_view(cell1); cout << "cell value: " << f(get_atom::value) << endl; f(put_atom::value, 20); cout << "cell value (after setting to 20): " << f(get_atom::value) << endl; // get an unchecked cell and send it some garbage anon_send(cell2, "hello there!"); }
void caf_main(actor_system& sys, const config& cfg) { auto& mm = sys.middleman(); auto self =sys.spawn(math); if (cfg.server) { auto p = mm.publish(self, cfg.port); if (!p) cerr << "unable to publish actor: " << sys.render(p.error()) << "\n"; else cout << "math actor published at port " << *p << "\n"; } else { auto x = mm.remote_actor(cfg.host, cfg.port); if (!x) cerr << "unable to connect to server: " << sys.render(x.error()) << "\n"; else { //self->send(*x,1); auto f = make_function_view(*x); cout << "f('add', 4, 2) = " << f(add_atom::value, 4, 2) << "\n" << "f('sub', 4, 2) = " << f(sub_atom::value, 4, 2) << "\n" << "f('mul', 4, 2) = " << f(mul_atom::value, 4, 2) << "\n" << "f('div', 4, 2) = " << f(div_atom::value, 4, 2) << "\n" << "f('div', 1, 0) = " << f(div_atom::value, 1, 0) << "\n"; } } }