Наследование: OtpErlangObject
Пример #1
0
        public override Object Clone()
        {
            OtpErlangRef newRef = (OtpErlangRef)base.Clone();

            newRef.ids = (int[])ids.Clone();
            return(newRef);
        }
Пример #2
0
        /**
         * Create an Erlang ref from a stream containing a ref encoded in Erlang
         * external format.
         *
         * @param buf
         *                the stream containing the encoded ref.
         *
         * @exception OtpErlangDecodeException
         *                    if the buffer does not contain a valid external
         *                    representation of an Erlang ref.
         */
        public OtpErlangRef(OtpInputStream buf)
        {
            OtpErlangRef r = buf.read_ref();

            node     = r.Node;
            creation = r.Creation;
            ids      = r.Ids;
        }
Пример #3
0
        public OtpErlangRef(OtpLocalNode self)
        {
            OtpErlangRef r = self.createRef();

            ids      = r.Ids;
            creation = r.Creation;
            node     = r.Node;
        }
Пример #4
0
        /**
         * Write an Erlang ref to the stream.
         */
        public void WriteRef(OtpErlangRef r)
        {
            int arity = r.Ids.Length;

            Write1(OtpExternal.newerRefTag);
            Write2BE(arity);
            WriteAtom(r.Node);
            Write4BE(r.Creation);
            for (int i = 0; i < arity; i++)
            {
                Write4BE(r.Ids[i]);
            }
        }
Пример #5
0
        /**
         * Determine if two refs are equal. Refs are equal if their components are
         * equal. New refs and old refs are considered equal if the node, creation
         * and first id numnber are equal.
         *
         * @param o
         *                the other ref to compare to.
         *
         * @return true if the refs are equal, false otherwise.
         */
        public override bool Equals(Object o)
        {
            if (!(o is OtpErlangRef))
            {
                return(false);
            }

            OtpErlangRef r = (OtpErlangRef)o;

            if (!(node.Equals(r.Node) && creation == r.Creation))
            {
                return(false);
            }

            if (isNewRef() && r.isNewRef())
            {
                return(ids[0] == r.Ids[0] && ids[1] == r.Ids[1] && ids[2] == r.Ids[2]);
            }
            return(ids[0] == r.Ids[0]);
        }
Пример #6
0
        /**
         * Create an Erlang {@link OtpErlangRef reference}. Erlang references are
         * based upon some node specific information; this method creates a
         * reference using the information in this node. Each call to this method
         * produces a unique reference.
         *
         * @return an Erlang reference.
         */
        public OtpErlangRef createRef()
        {
            lock (this)
            {
                OtpErlangRef r = new OtpErlangRef(base.Node, refId, base.Creation);

                // increment ref ids (3 ints: 18 + 32 + 32 bits)
                refId[0]++;
                if (refId[0] > 0x3ffff)
                {
                    refId[0] = 0;

                    refId[1]++;
                    if (refId[1] == 0)
                    {
                        refId[2]++;
                    }
                }

                return(r);
            }
        }
Пример #7
0
        /**
         * Create an Erlang {@link OtpErlangRef reference}. Erlang references are
         * based upon some node specific information; this method creates a
         * reference using the information in this node. Each call to this method
         * produces a unique reference.
         */
        public OtpErlangRef CreateRef()
        {
            lock (lockObj)
            {
                OtpErlangRef newRef = new OtpErlangRef(OtpExternal.newerRefTag, Node, refId, Creation);

                // increment ref ids (3 ints: 18 + 32 + 32 bits)
                refId[0]++;
                if (refId[0] > 0x3ffff)
                {
                    refId[0] = 0;

                    refId[1]++;
                    if (refId[1] == 0)
                    {
                        refId[2]++;
                    }
                }

                return(newRef);
            }
        }
Пример #8
0
        /**
         * Create an Erlang {@link OtpErlangRef reference}. Erlang references are
         * based upon some node specific information; this method creates a
         * reference using the information in this node. Each call to this method
         * produces a unique reference.
         *
         * @return an Erlang reference.
         */
        public OtpErlangRef createRef()
        {
            lock (this)
            {
                OtpErlangRef r = new OtpErlangRef(base.Node, refId, base.Creation);

                // increment ref ids (3 ints: 18 + 32 + 32 bits)
                refId[0]++;
                if (refId[0] > 0x3ffff)
                {
                    refId[0] = 0;

                    refId[1]++;
                    if (refId[1] == 0)
                    {
                        refId[2]++;
                    }
                }

                return r;
            }
        }