Esempio n. 1
0
        /*
         * 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;
        }
Esempio n. 2
0
        /**
         * Wait for a message to arrive for this mailbox.
         *
         * @param timeout
         *                the time, in milliseconds, to wait for a message.
         *
         * @return an {@link OtpMsg OtpMsg} containing the header information as
         *         well as the body of the next message waiting in this mailbox.
         *
         * @exception OtpErlangExit
         *                    if a linked {@link OtpErlangPid pid} has exited or has
         *                    sent an exit signal to this mailbox.
         *
         * @exception InterruptedException
         *                    if no message if the method times out before a message
         *                    becomes available.
         */
        public virtual OtpMsg receiveMsg(long timeout)
        {
            OtpMsg m = (OtpMsg)queue.get(timeout);

            if (m == null)
            {
                return(null);
            }

            switch (m.type())
            {
            case OtpMsg.exitTag:
            case OtpMsg.exit2Tag:
                try
                {
                    OtpErlangObject o = m.getMsg();
                    throw new OtpErlangExit(o, m.getSenderPid());
                }
                catch (OtpErlangDecodeException)
                {
                    throw new OtpErlangExit("unknown", m.getSenderPid());
                }

            default:
                return(m);
            }
        }
Esempio n. 3
0
        /*
         * called by OtpNode to deliver message to this mailbox.
         *
         * About exit and exit2: both cause exception to be raised upon receive().
         * However exit (not 2) causes any link to be removed as well, while exit2
         * leaves any links intact.
         */
        public virtual void deliver(OtpMsg m)
        {
            switch (m.type())
            {
            case OtpMsg.linkTag:
                links.addLink(self, m.getSenderPid());
                break;

            case OtpMsg.unlinkTag:
                links.removeLink(self, m.getSenderPid());
                break;

            case OtpMsg.exitTag:
                links.removeLink(self, m.getSenderPid());
                queue.put(m);
                break;

            case OtpMsg.exit2Tag:
            default:
                queue.put(m);
                break;
            }
        }
        /*
         * 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;
        }
        /*
         * called by OtpNode to deliver message to this mailbox.
         *
         * About exit and exit2: both cause exception to be raised upon receive().
         * However exit (not 2) causes any link to be removed as well, while exit2
         * leaves any links intact.
         */
        public virtual void deliver(OtpMsg m)
        {
            switch (m.type())
            {
                case OtpMsg.linkTag:
                    links.addLink(self, m.getSenderPid());
                    break;

                case OtpMsg.unlinkTag:
                    links.removeLink(self, m.getSenderPid());
                    break;

                case OtpMsg.exitTag:
                    links.removeLink(self, m.getSenderPid());
                    queue.put(m);
                    break;

                case OtpMsg.exit2Tag:
                default:
                    queue.put(m);
                    break;
            }
        }