Ejemplo n.º 1
0
        protected void SendOwn(Own destination, Own obj)
        {
            destination.IncSeqnum();
            Command cmd = new Command(destination, CommandType.Own, obj);

            SendCommand(cmd);
        }
Ejemplo n.º 2
0
        protected void SendTermReq(Own destination,
                                   Own object_)
        {
            Command cmd = new Command(destination, CommandType.TermReq, object_);

            SendCommand(cmd);
        }
Ejemplo n.º 3
0
Archivo: Own.cs Proyecto: xuzhe35/netmq
        protected override void ProcessTermReq(Own object_)
        {
            //  When shutting down we can ignore termination requests from owned
            //  objects. The termination request was already sent to the object.
            if (m_terminating)
            {
                return;
            }

            //  If I/O object is well and alive let's ask it to terminate.

            //  If not found, we assume that termination request was already sent to
            //  the object so we can safely ignore the request.
            if (!m_owned.Contains(object_))
            {
                return;
            }

            m_owned.Remove(object_);
            RegisterTermAcks(1);

            //  Note that this object is the root of the (partial shutdown) thus, its
            //  value of linger is used, rather than the value stored by the children.
            SendTerm(object_, m_options.Linger);
        }
Ejemplo n.º 4
0
Archivo: Own.cs Proyecto: xuzhe35/netmq
 /// <summary> Initializes a new instance of the <see cref="Own" /> class that is running within I/O thread. </summary>
 /// <param name="ioThread">The I/O thread.</param>
 /// <param name="options">The options.</param>
 /// <remarks> Note that the owner is unspecified in the constructor. It'll be assigned later on using <see cref="SetOwner"/>
 /// when the object is plugged in. </remarks>
 protected Own(IOThread ioThread, Options options)
     : base(ioThread)
 {
     m_options         = options;
     m_terminating     = false;
     m_processedSeqnum = 0;
     m_owner           = null;
     m_termAcks        = 0;
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Send the Plug command, incrementing the destinations sequence-number if incSeqnum is true.
        /// </summary>
        /// <param name="destination">the Own to send the command to</param>
        /// <param name="incSeqnum">a flag that dictates whether to increment the sequence-number on the destination (optional - defaults to false)</param>
        protected void SendPlug([NotNull] Own destination, bool incSeqnum = true)
        {
            if (incSeqnum)
            {
                destination.IncSeqnum();
            }

            SendCommand(new Command(destination, CommandType.Plug));
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Send the Bind command
        /// </summary>
        /// <param name="destination"></param>
        /// <param name="pipe"></param>
        /// <param name="incSeqnum"></param>
        protected void SendBind([NotNull] Own destination, [NotNull] Pipe pipe, bool incSeqnum = true)
        {
            if (incSeqnum)
            {
                destination.IncSeqnum();
            }

            SendCommand(new Command(destination, CommandType.Bind, pipe));
        }
Ejemplo n.º 7
0
Archivo: Own.cs Proyecto: xuzhe35/netmq
        /// <summary> Initializes a new instance of the <see cref="Own" /> class that is running on a thread outside of 0MQ infrastructure. </summary>
        /// <param name="parent">The parent context.</param>
        /// <param name="threadId">The thread id.</param>
        /// <remarks> Note that the owner is unspecified in the constructor. It'll be assigned later on using <see cref="SetOwner"/>
        /// when the object is plugged in. </remarks>
        protected Own(Ctx parent, int threadId)
            : base(parent, threadId)
        {
            m_terminating     = false;
            m_processedSeqnum = 0;
            m_owner           = null;
            m_termAcks        = 0;

            m_options = new Options();
        }
Ejemplo n.º 8
0
        /// <summary> Initializes a new instance of the <see cref="Own" /> class that is running on a thread outside of 0MQ infrastructure. </summary>
        /// <param name="parent">The parent context.</param>
        /// <param name="threadId">The thread id.</param>
        /// <remarks> Note that the owner is unspecified in the constructor. It'll be assigned later on using <see cref="SetOwner"/>
        /// when the object is plugged in. </remarks>
        protected Own(Ctx parent, int threadId)
            : base(parent, threadId)
        {
            m_terminating = false;
            m_processedSeqnum = 0;
            m_owner = null;
            m_termAcks = 0;

            m_options = new Options();
        }
Ejemplo n.º 9
0
Archivo: Own.cs Proyecto: xuzhe35/netmq
        /// <summary> Launch the supplied object and become its owner. </summary>
        /// <param name="object_">The object to be launched.</param>
        protected void LaunchChild(Own object_)
        {
            //  Specify the owner of the object.
            object_.SetOwner(this);

            //  Plug the object into the I/O thread.
            SendPlug(object_);

            //  Take ownership of the object.
            SendOwn(this, object_);
        }
Ejemplo n.º 10
0
        protected void SendBind(Own destination, Pipe pipe, bool incSeqnum = true)
        {
            if (incSeqnum)
            {
                destination.IncSeqnum();
            }

            Command cmd = new Command(destination, CommandType.Bind, pipe);

            SendCommand(cmd);
        }
Ejemplo n.º 11
0
        protected void SendPlug(Own destination, bool incSeqnum = true)
        {
            if (incSeqnum)
            {
                destination.IncSeqnum();
            }

            Command cmd = new Command(destination, CommandType.Plug);

            SendCommand(cmd);
        }
Ejemplo n.º 12
0
        //  Note that the owner is unspecified in the constructor.
        //  It'll be supplied later on when the object is plugged in.
        //  The object is not living within an I/O thread. It has it's own
        //  thread outside of 0MQ infrastructure.
        public Own(Ctx parent, int tid)
            : base(parent, tid)
        {
            m_terminating = false;
            m_sentSeqnum = new AtomicLong(0);
            m_processedSeqnum = 0;
            m_owner = null;
            m_termAcks = 0;

            m_options = new Options();
            owned = new HashSet<Own>();
        }
Ejemplo n.º 13
0
Archivo: Own.cs Proyecto: xuzhe35/netmq
        protected override void ProcessOwn(Own object_)
        {
            //  If the object is already being shut down, new owned objects are
            //  immediately asked to terminate. Note that linger is set to zero.
            if (m_terminating)
            {
                RegisterTermAcks(1);
                SendTerm(object_, 0);
                return;
            }

            //  Store the reference to the owned object.
            m_owned.Add(object_);
        }
Ejemplo n.º 14
0
        protected override void ProcessOwn(Own object_)
        {
            //  If the object is already being shut down, new owned objects are
            //  immediately asked to terminate. Note that linger is set to zero.
            if (m_terminating)
            {
                RegisterTermAcks(1);
                SendTerm(object_, 0);
                return;
            }

            //  Store the reference to the owned object.
            m_owned.Add(object_);
        }
Ejemplo n.º 15
0
 /// <summary>
 /// Creates new endpoint ID and adds the endpoint to the map.
 /// </summary>
 private void AddEndpoint([NotNull] string addr, [NotNull] Own endpoint)
 {
     //  Activate the session. Make it a child of this socket.
     LaunchChild(endpoint);
     m_endpoints[addr] = endpoint;
 }
Ejemplo n.º 16
0
 protected void SendBind(Own destination, Pipe pipe)
 {
     SendBind(destination, pipe, true);
 }
Ejemplo n.º 17
0
 protected void SendOwn(Own destination, Own obj)
 {
     destination.IncSeqnum ();
     Command cmd = new Command(destination, CommandType.Own, obj);
     SendCommand (cmd);
 }
Ejemplo n.º 18
0
        protected void SendTerm(Own destination, int linger)
        {
            Command cmd = new Command(destination, CommandType.Term, linger);

            SendCommand(cmd);
        }
Ejemplo n.º 19
0
 protected virtual void ProcessTermReq(Own obj)
 {
     throw new NotSupportedException();
 }
Ejemplo n.º 20
0
        protected void SendPlug(Own destination, bool incSeqnum)
        {
            if (incSeqnum)
                destination.IncSeqnum ();

            Command cmd = new Command(destination, CommandType.Plug);
            SendCommand (cmd);
        }
Ejemplo n.º 21
0
 protected void SendTermAck(Own destination)
 {
     Command cmd = new Command(destination, CommandType.TermAck);
     SendCommand (cmd);
 }
Ejemplo n.º 22
0
 /// <summary> Terminate owned object. </summary>
 /// <param name="object_"></param>
 protected void TermChild(Own object_)
 {
     ProcessTermReq(object_);
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Send the Own command, and increment the sequence-number of the destination
 /// </summary>
 /// <param name="destination">the Own to send the command to</param>
 /// <param name="obj">the object to Own</param>
 protected void SendOwn([NotNull] Own destination, [NotNull] Own obj)
 {
     destination.IncSeqnum();
     SendCommand(new Command(destination, CommandType.Own, obj));
 }
Ejemplo n.º 24
0
Archivo: Own.cs Proyecto: xuzhe35/netmq
 private void SetOwner(Own owner)
 {
     Debug.Assert(m_owner == null);
     m_owner = owner;
 }
Ejemplo n.º 25
0
 private void SetOwner(Own owner)
 {
     Debug.Assert(m_owner == null);
     m_owner = owner;
 }
Ejemplo n.º 26
0
 /// <summary> Initializes a new instance of the <see cref="Own" /> class that is running within I/O thread. </summary>
 /// <param name="ioThread">The I/O thread.</param>
 /// <param name="options">The options.</param>
 /// <remarks> Note that the owner is unspecified in the constructor. It'll be assigned later on using <see cref="SetOwner"/>
 /// when the object is plugged in. </remarks>
 protected Own(IOThread ioThread, Options options)
     : base(ioThread)
 {
     m_options = options;
     m_terminating = false;
     m_processedSeqnum = 0;
     m_owner = null;
     m_termAcks = 0;
 }
Ejemplo n.º 27
0
        /// <summary> Launch the supplied object and become its owner. </summary>
        /// <param name="object_">The object to be launched.</param>
        protected void LaunchChild(Own object_)
        {
            //  Specify the owner of the object.
            object_.SetOwner(this);

            //  Plug the object into the I/O thread.
            SendPlug(object_);

            //  Take ownership of the object.
            SendOwn(this, object_);
        }
Ejemplo n.º 28
0
        //  The object is living within I/O thread.
        public Own(IOThread ioThread, Options options)
            : base(ioThread)
        {
            m_options = options;
            m_terminating = false;
            m_sentSeqnum = new AtomicLong(0);
            m_processedSeqnum = 0;
            m_owner = null;
            m_termAcks = 0;

            owned = new HashSet<Own>();
        }
Ejemplo n.º 29
0
 /// <summary>
 /// Terminate owned object.
 /// </summary>
 /// <param name="obj"></param>
 protected void TermChild([NotNull] Own obj)
 {
     ProcessTermReq(obj);
 }
Ejemplo n.º 30
0
 protected void SendTermAck([NotNull] Own destination)
 {
     SendCommand(new Command(destination, CommandType.TermAck));
 }
Ejemplo n.º 31
0
        protected void SendTermAck(Own destination)
        {
            Command cmd = new Command(destination, CommandType.TermAck);

            SendCommand(cmd);
        }
Ejemplo n.º 32
0
 protected virtual void ProcessOwn([NotNull] Own obj)
 {
     throw new NotSupportedException();
 }
Ejemplo n.º 33
0
 protected virtual void ProcessTermReq(Own obj)
 {
     throw new NotSupportedException();
 }
Ejemplo n.º 34
0
        protected override void ProcessTermReq(Own object_)
        {
            //  When shutting down we can ignore termination requests from owned
            //  objects. The termination request was already sent to the object.
            if (m_terminating)
                return;

            //  If I/O object is well and alive let's ask it to terminate.

            //  If not found, we assume that termination request was already sent to
            //  the object so we can safely ignore the request.
            if (!m_owned.Contains(object_))
                return;

            m_owned.Remove(object_);
            RegisterTermAcks(1);

            //  Note that this object is the root of the (partial shutdown) thus, its
            //  value of linger is used, rather than the value stored by the children.
            SendTerm(object_, m_options.Linger);
        }
Ejemplo n.º 35
0
        protected void SendBind(Own destination, Pipe pipe,
		                          bool incSeqnum)
        {
            if (incSeqnum)
                destination.IncSeqnum ();

            Command cmd = new Command(destination, CommandType.Bind, pipe);
            SendCommand (cmd);
        }
Ejemplo n.º 36
0
 //  Creates new endpoint ID and adds the endpoint to the map.
 private void AddEndpoint(String addr, Own endpoint)
 {
     //  Activate the session. Make it a child of this socket.
     LaunchChild(endpoint);
     m_endpoints[addr] = endpoint;
 }
Ejemplo n.º 37
0
 protected void SendPlug(Own destination)
 {
     SendPlug(destination, true);
 }
Ejemplo n.º 38
0
Archivo: Own.cs Proyecto: xuzhe35/netmq
 /// <summary> Terminate owned object. </summary>
 /// <param name="object_"></param>
 protected void TermChild(Own object_)
 {
     ProcessTermReq(object_);
 }
Ejemplo n.º 39
0
 protected void SendTerm(Own destination, int linger)
 {
     Command cmd = new Command(destination, CommandType.Term, linger);
     SendCommand (cmd);
 }
Ejemplo n.º 40
0
 protected void SendTermReq([NotNull] Own destination, [NotNull] Own obj)
 {
     SendCommand(new Command(destination, CommandType.TermReq, obj));
 }
Ejemplo n.º 41
0
        protected void SendTermReq(Own destination,
		                              Own object_)
        {
            Command cmd = new Command(destination, CommandType.TermReq, object_);
            SendCommand (cmd);
        }
Ejemplo n.º 42
0
 protected void SendTerm([NotNull] Own destination, int linger)
 {
     SendCommand(new Command(destination, CommandType.Term, linger));
 }