get() публичный Метод

public get ( ) : Object
Результат System.Object
Пример #1
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 Exit if a linked {@link Pid 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;

            try {
                m = (OtpMsg)queue.get(timeout);
            } catch (System.Threading.ThreadInterruptedException) {
                m = null;
            }

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

            switch (m.type())
            {
            case OtpMsg.Tag.exitTag:
            case OtpMsg.Tag.exit2Tag:
                try
                {
                    Erlang.Object o = m.getMsg();
                    throw new Erlang.Exit(o.ToString(), m.getSenderPid());
                }
                catch (Erlang.DecodeException)
                {
                    throw new Erlang.Exit("unknown", m.getSenderPid());
                }

            default:
                return(m);
            }
        }
Пример #2
0
        /*
         * Receive a messge complete with sender and recipient information.
         * This method blocks at most for the specified time.
         *
         * @param timeout the time in milliseconds that this operation will
         * block. Specify 0 to poll the queue.
         *
         * @return an {@link OtpMsg OtpMsg} containing the header
         * information about the sender and recipient, as well as the actual
         * message contents.
         *
         * @exception C#.io.IOException if the connection is not active or
         * a communication error occurs.
         *
         * @exception Erlang.Exit if an exit signal is received from a
         * process on the peer node, or if the connection is lost for any
         * reason.
         *
         * @exception OtpAuthException if the remote node
         * sends a message containing an invalid cookie.
         *
         * @exception InterruptedException if no message if the method
         * times out before a message becomes available.
         **/
        public virtual OtpMsg receiveMsg(long timeout)
        {
            System.Object o = timeout == -1 ? queue.get() : queue.get(timeout);

            if (o is OtpMsg)
            {
                return((OtpMsg)o);
            }
            else if (o is System.IO.IOException)
            {
                throw (System.IO.IOException)o;
            }
            else if (o is Erlang.Exit)
            {
                throw (Erlang.Exit)o;
            }
            else if (o is OtpAuthException)
            {
                throw (OtpAuthException)o;
            }

            return(null);
        }