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

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

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

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

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

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

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

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