예제 #1
0
파일: process.cpp 프로젝트: Agerran/gluonvm
void Process::msg_send(Term pid, Term value) {
  // TODO: send to tuple {dst,node}, and to registered atom, and to port
  G_ASSERT(pid.is_pid());

  Process* other = vm_.scheduler().find(pid);
  if (!other) {
    Std::fmt(tRed("msg_send pid not found: "));
    pid.println(vm_);
    return;
  }
  // Clone local value to value on remote heap
  Term dst_value = proc::copy_one_term(vm_, other->get_heap(), value);
  other->mailbox().on_incoming(dst_value);
  vm_.scheduler().on_new_message(other);  // wake up receiver
}
예제 #2
0
Term bif_register_2(Process* p, Term name, Term pid_port) {
  if (!name.is_atom() || name == atom::UNDEFINED) {
    return p->error_badarg(name);
  }
  if (!pid_port.is_pid() && !pid_port.is_port()) {
    return p->error_badarg(pid_port);
  }
  switch (p->vm().register_name(name, pid_port)) {
    case RegisterResult::Ok:
      return atom::TRUE;
    case RegisterResult::RegistrationExists:  // fall through
    case RegisterResult::ProcessNotFound:
      return p->error_badarg(pid_port);
  }
}