void abstract_broker::launch(execution_unit*, bool, bool is_hidden) {
  // add implicit reference count held by the middleman
  ref();
  is_registered(! is_hidden);
  CAF_PUSH_AID(id());
  CAF_LOGF_TRACE("init and launch broker with ID " << id());
  // we want to make sure initialization is executed in MM context
  do_become(
    [=](sys_atom) {
      CAF_LOGF_TRACE("ID " << id());
      bhvr_stack_.pop_back();
      // launch backends now, because user-defined initialization
      // might call functions like add_connection
      for (auto& kvp : doormen_) {
        kvp.second->launch();
      }
      initialize();
    },
    true);
  enqueue(invalid_actor_addr, invalid_message_id,
          make_message(sys_atom::value), nullptr);
}
Example #2
0
// initializes singleton
node_id::data* node_id::data::create_singleton() {
    CAF_LOGF_TRACE("");
    auto ifs = detail::get_mac_addresses();
    std::vector<std::string> macs;
    macs.reserve(ifs.size());
    for (auto& i : ifs) {
        macs.emplace_back(std::move(i.second));
    }
    auto hd_serial_and_mac_addr = join(macs, "") + detail::get_root_uuid();
    node_id::host_id_type nid;
    detail::ripemd_160(nid, hd_serial_and_mac_addr);
    // note: pointer has a ref count of 1 -> implicitly held by detail::singletons
    return new node_id::data(detail::get_process_id(), nid);
}
Example #3
0
void unpublish_impl(const actor_addr& whom, uint16_t port, bool blocking) {
  CAF_LOGF_TRACE(CAF_TSARG(whom) << ", " << CAF_ARG(port) << CAF_ARG(blocking));
  auto mm = get_middleman_actor();
  if (blocking) {
    scoped_actor self;
    self->sync_send(mm, unpublish_atom::value, whom, port).await(
      [](ok_atom) {
        // ok, basp_broker is done
      },
      [](error_atom, const std::string&) {
        // ok, basp_broker is done
      }
    );
  } else {
    anon_send(mm, unpublish_atom::value, whom, port);
  }
}
size_t abstract_actor::detach_impl(const attachable::token& what,
                                   attachable_ptr& ptr,
                                   bool stop_on_hit,
                                   bool dry_run) {
  CAF_LOGF_TRACE("");
  if (! ptr) {
    CAF_LOGF_DEBUG("invalid ptr");
    return 0;
  }
  if (ptr->matches(what)) {
    if (! dry_run) {
      CAF_LOGF_DEBUG("removed element");
      attachable_ptr next;
      next.swap(ptr->next);
      ptr.swap(next);
    }
    return stop_on_hit ? 1 : 1 + detach_impl(what, ptr, stop_on_hit, dry_run);
  }
  return detach_impl(what, ptr->next, stop_on_hit, dry_run);
}