Inheritance: IDisposable
Example #1
0
        /* create the outgoing ping message */
        private OtpErlangTuple getPingTuple(OtpMbox mbox)
        {
            OtpErlangObject[] ping = new OtpErlangObject[3];
            OtpErlangObject[] pid = new OtpErlangObject[2];
            OtpErlangObject[] node = new OtpErlangObject[2];

            pid[0] = mbox.Self;
            pid[1] = createRef();

            node[0] = new OtpErlangAtom("is_auth");
            node[1] = new OtpErlangAtom(Node);

            ping[0] = new OtpErlangAtom("$gen_call");
            ping[1] = new OtpErlangTuple(pid);
            ping[2] = new OtpErlangTuple(node);

            return new OtpErlangTuple(ping);
        }
Example #2
0
 /**
  * <p>
  * Register or remove a name for the given mailbox. Registering a name for a
  * mailbox enables others to send messages without knowing the
  * {@link OtpErlangPid pid} of the mailbox. A mailbox can have at most one
  * name; if the mailbox already had a name, calling this method will
  * supercede that name.
  * </p>
  *
  * @param name
  *            the name to register for the mailbox. Specify null to
  *            unregister the existing name from this mailbox.
  *
  * @param mbox
  *            the mailbox to associate with the name.
  *
  * @return true if the name was available, or false otherwise.
  */
 public bool registerName(String name, OtpMbox mbox)
 {
     return mboxes.register(name, mbox);
 }
Example #3
0
 /**
  * Close the specified mailbox with the given reason.
  *
  * @param mbox
  *            the mailbox to close.
  * @param reason
  *            an Erlang term describing the reason for the termination.
  *
  *            <p>
  *            After this operation, the mailbox will no longer be able to
  *            receive messages. Any delivered but as yet unretrieved
  *            messages can still be retrieved however.
  *            </p>
  *
  *            <p>
  *            If there are links from the mailbox to other
  *            {@link OtpErlangPid pids}, they will be broken when this
  *            method is called and exit signals with the given reason will
  *            be sent.
  *            </p>
  *
  */
 public void closeMbox(OtpMbox mbox, OtpErlangObject reason)
 {
     if (mbox != null)
     {
         mboxes.remove(mbox);
         mbox.Name = null;
         mbox.breakLinks(reason);
     }
 }
Example #4
0
 /**
  * Close the specified mailbox with reason 'normal'.
  *
  * @param mbox
  *            the mailbox to close.
  *
  *            <p>
  *            After this operation, the mailbox will no longer be able to
  *            receive messages. Any delivered but as yet unretrieved
  *            messages can still be retrieved however.
  *            </p>
  *
  *            <p>
  *            If there are links from the mailbox to other
  *            {@link OtpErlangPid pids}, they will be broken when this
  *            method is called and exit signals with reason 'normal' will be
  *            sent.
  *            </p>
  *
  */
 public void closeMbox(OtpMbox mbox)
 {
     closeMbox(mbox, new OtpErlangAtom("normal"));
 }
Example #5
0
 public void remove(OtpMbox mbox)
 {
     lock (this)
     {
         byPid.Remove(mbox.Self);
         if (mbox.Name != null)
         {
             byName.Remove(mbox.Name);
         }
     }
 }
Example #6
0
 public bool register(String name, OtpMbox mbox)
 {
     lock (this)
     {
         if (name == null)
         {
             if (mbox.Name != null)
             {
                 byName.Remove(mbox.Name);
                 mbox.Name = null;
             }
         }
         else
         {
             if (get(name) != null)
             {
                 return false;
             }
             byName.Add(name, new WeakReference(mbox));
             mbox.Name = name;
         }
     }
     return true;
 }