public addLink ( |
||
local | ||
remote | ||
Результат | void |
/* * pass the message to the node for final delivery. Note that the connection * itself needs to know about links (in case of connection failure), so we * snoop for link/unlink too here. */ public override void deliver(OtpMsg msg) { bool delivered = self.deliver(msg); switch (msg.type()) { case OtpMsg.linkTag: if (delivered) { links.addLink(msg.getRecipientPid(), msg.getSenderPid()); } else { try { // no such pid - send exit to sender base.sendExit(msg.getRecipientPid(), msg.getSenderPid(), new OtpErlangAtom("noproc")); } catch (IOException) { } } break; case OtpMsg.unlinkTag: case OtpMsg.exitTag: links.removeLink(msg.getRecipientPid(), msg.getSenderPid()); break; case OtpMsg.exit2Tag: break; } return; }
/** * <p> * Link to a remote mailbox or Erlang process. Links are idempotent, calling * this method multiple times will not result in more than one link being * created. * </p> * * <p> * If the remote process subsequently exits or the mailbox is closed, a * subsequent attempt to retrieve a message through this mailbox will cause * an {@link OtpErlangExit OtpErlangExit} exception to be raised. Similarly, * if the sending mailbox is closed, the linked mailbox or process will * receive an exit signal. * </p> * * <p> * If the remote process cannot be reached in order to set the link, the * exception is raised immediately. * </p> * * @param to * the {@link OtpErlangPid pid} representing the object to * link to. * * @exception OtpErlangExit * if the {@link OtpErlangPid pid} referred to does not * exist or could not be reached. * */ public void link(OtpErlangPid to) { try { String node = to.Node; if (node.Equals(home.Node)) { if (!home.deliver(new OtpMsg(OtpMsg.linkTag, self, to))) { throw new OtpErlangExit("noproc", to); } } else { OtpCookedConnection conn = home.getConnection(node); if (conn != null) { conn.link(self, to); } else { throw new OtpErlangExit("noproc", to); } } } catch (OtpErlangExit e) { throw e; } catch (Exception) { } links.addLink(self, to); }