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

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

            SendCommand(cmd);
        }
Example #3
0
File: Own.cs Project: 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);
        }
Example #4
0
File: Own.cs Project: 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;
 }
Example #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));
        }
Example #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));
        }
Example #7
0
File: Own.cs Project: 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();
        }
Example #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();
        }
Example #9
0
File: Own.cs Project: 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_);
        }
Example #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);
        }
Example #11
0
        protected void SendPlug(Own destination, bool incSeqnum = true)
        {
            if (incSeqnum)
            {
                destination.IncSeqnum();
            }

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

            SendCommand(cmd);
        }
Example #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>();
        }
Example #13
0
File: Own.cs Project: 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_);
        }
Example #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_);
        }
Example #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;
 }
Example #16
0
 protected void SendBind(Own destination, Pipe pipe)
 {
     SendBind(destination, pipe, true);
 }
Example #17
0
 protected void SendOwn(Own destination, Own obj)
 {
     destination.IncSeqnum ();
     Command cmd = new Command(destination, CommandType.Own, obj);
     SendCommand (cmd);
 }
Example #18
0
        protected void SendTerm(Own destination, int linger)
        {
            Command cmd = new Command(destination, CommandType.Term, linger);

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

            Command cmd = new Command(destination, CommandType.Plug);
            SendCommand (cmd);
        }
Example #21
0
 protected void SendTermAck(Own destination)
 {
     Command cmd = new Command(destination, CommandType.TermAck);
     SendCommand (cmd);
 }
Example #22
0
 /// <summary> Terminate owned object. </summary>
 /// <param name="object_"></param>
 protected void TermChild(Own object_)
 {
     ProcessTermReq(object_);
 }
Example #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));
 }
Example #24
0
File: Own.cs Project: xuzhe35/netmq
 private void SetOwner(Own owner)
 {
     Debug.Assert(m_owner == null);
     m_owner = owner;
 }
Example #25
0
 private void SetOwner(Own owner)
 {
     Debug.Assert(m_owner == null);
     m_owner = owner;
 }
Example #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;
 }
Example #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_);
        }
Example #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>();
        }
Example #29
0
 /// <summary>
 /// Terminate owned object.
 /// </summary>
 /// <param name="obj"></param>
 protected void TermChild([NotNull] Own obj)
 {
     ProcessTermReq(obj);
 }
Example #30
0
 protected void SendTermAck([NotNull] Own destination)
 {
     SendCommand(new Command(destination, CommandType.TermAck));
 }
Example #31
0
        protected void SendTermAck(Own destination)
        {
            Command cmd = new Command(destination, CommandType.TermAck);

            SendCommand(cmd);
        }
Example #32
0
 protected virtual void ProcessOwn([NotNull] Own obj)
 {
     throw new NotSupportedException();
 }
Example #33
0
 protected virtual void ProcessTermReq(Own obj)
 {
     throw new NotSupportedException();
 }
Example #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);
        }
Example #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);
        }
Example #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;
 }
Example #37
0
 protected void SendPlug(Own destination)
 {
     SendPlug(destination, true);
 }
Example #38
0
File: Own.cs Project: xuzhe35/netmq
 /// <summary> Terminate owned object. </summary>
 /// <param name="object_"></param>
 protected void TermChild(Own object_)
 {
     ProcessTermReq(object_);
 }
Example #39
0
 protected void SendTerm(Own destination, int linger)
 {
     Command cmd = new Command(destination, CommandType.Term, linger);
     SendCommand (cmd);
 }
Example #40
0
 protected void SendTermReq([NotNull] Own destination, [NotNull] Own obj)
 {
     SendCommand(new Command(destination, CommandType.TermReq, obj));
 }
Example #41
0
        protected void SendTermReq(Own destination,
		                              Own object_)
        {
            Command cmd = new Command(destination, CommandType.TermReq, object_);
            SendCommand (cmd);
        }
Example #42
0
 protected void SendTerm([NotNull] Own destination, int linger)
 {
     SendCommand(new Command(destination, CommandType.Term, linger));
 }