void actor_registry::put(actor_id key, const actor_ptr& value) { bool add_attachable = false; if (value != nullptr) { shared_guard guard(m_instances_mtx); auto i = m_entries.find(key); if (i == m_entries.end()) { auto entry = std::make_pair(key, value_type(value, exit_reason::not_exited)); upgrade_guard uguard(guard); add_attachable = m_entries.insert(entry).second; } } if (add_attachable) { CPPA_LOG_INFO("added " << key); struct eraser : attachable { actor_id m_id; actor_registry* m_registry; eraser(actor_id id, actor_registry* s) : m_id(id), m_registry(s) { } void actor_exited(std::uint32_t reason) { m_registry->erase(m_id, reason); } bool matches(const token&) { return false; } }; value->attach(new eraser(key, this)); } }
void local_actor::monitor(const actor_ptr& whom) { if (whom) whom->attach(attachable_ptr{new down_observer(this, whom)}); }
void local_actor::monitor(actor_ptr whom) { if (whom) whom->attach(new down_observer(this, whom)); }