inline std::string to_string(const node_info& x) { return "node_info" + deep_to_string(std::forward_as_tuple(x.source_node, x.cpu, x.hostname, x.os, x.interfaces)); }
std::string to_string(const node_id& x) { if (!x) return "none"; return deep_to_string(meta::type_name("node_id"), x.process_id(), meta::hex_formatted(), x.host_id()); }
std::string to_string(const optional<T>& x) { return x ? "*" + deep_to_string(*x) : "none"; }
std::string to_string() const override { return deep_to_string(ref_); }
std::string stringify() const override { return deep_to_string(x_); }
actor_system::actor_system(actor_system_config& cfg) : ids_(0), types_(*this), logger_(*this), registry_(*this), groups_(*this), middleman_(nullptr), dummy_execution_unit_(this), await_actors_before_shutdown_(true), detached(0), cfg_(cfg) { CAF_SET_LOGGER_SYS(this); for (auto& f : cfg.module_factories) { auto mod_ptr = f(*this); modules_[mod_ptr->id()].reset(mod_ptr); } auto& mmptr = modules_[module::middleman]; if (mmptr) middleman_ = reinterpret_cast<io::middleman*>(mmptr->subtype_ptr()); auto& clptr = modules_[module::opencl_manager]; if (clptr) opencl_manager_ = reinterpret_cast<opencl::manager*>(clptr->subtype_ptr()); auto& sched = modules_[module::scheduler]; using share = scheduler::coordinator<policy::work_sharing>; using steal = scheduler::coordinator<policy::work_stealing>; using profiled_share = scheduler::profiled_coordinator<policy::work_sharing>; using profiled_steal = scheduler::profiled_coordinator<policy::work_stealing>; // set scheduler only if not explicitly loaded by user if (!sched) { enum sched_conf { stealing = 0x0001, sharing = 0x0002, profiled = 0x0100, profiled_stealing = 0x0101, profiled_sharing = 0x0102 }; sched_conf sc = stealing; if (cfg.scheduler_policy == atom("sharing")) sc = sharing; else if (cfg.scheduler_policy != atom("stealing")) std::cerr << "[WARNING] " << deep_to_string(cfg.scheduler_policy) << " is an unrecognized scheduler pollicy, " "falling back to 'stealing' (i.e. work-stealing)" << std::endl; if (cfg.scheduler_enable_profiling) sc = static_cast<sched_conf>(sc | profiled); switch (sc) { default: // any invalid configuration falls back to work stealing sched.reset(new steal(*this)); break; case sharing: sched.reset(new share(*this)); break; case profiled_stealing: sched.reset(new profiled_steal(*this)); break; case profiled_sharing: sched.reset(new profiled_share(*this)); break; } } // initialize state for each module and give each module the opportunity // to influence the system configuration, e.g., by adding more types for (auto& mod : modules_) if (mod) mod->init(cfg); groups_.init(cfg); // spawn config and spawn servers (lazily to not access the scheduler yet) static constexpr auto Flags = hidden + lazy_init; spawn_serv_ = actor_cast<strong_actor_ptr>(spawn<Flags>(spawn_serv_impl)); config_serv_ = actor_cast<strong_actor_ptr>(spawn<Flags>(config_serv_impl)); // fire up remaining modules logger_.start(); registry_.start(); registry_.put(atom("SpawnServ"), spawn_serv_); registry_.put(atom("ConfigServ"), config_serv_); for (auto& mod : modules_) if (mod) mod->start(); groups_.start(); }