예제 #1
0
 /// <summary> Stop the rentransmition and clear all pending msgs.
 /// <p>
 /// If this retransmitter has been provided  an externally managed
 /// scheduler, then just clear all msgs and the associated tasks, else
 /// stop the scheduler. In this case the method blocks until the
 /// scheduler's thread is dead. Only the owner of the scheduler should
 /// stop it.
 /// </summary>
 public virtual void  stop()
 {
     // i. If retransmitter is owned, stop it else cancel all tasks
     // ii. Clear all pending msgs
     lock (msgs.SyncRoot)
     {
         if (retransmitter_owned)
         {
             try
             {
                 retransmitter.Dispose();
             }
             catch (System.Threading.ThreadInterruptedException ex)
             {
             }
         }
         else
         {
             for (int index = 0; index < msgs.Count; index++)
             {
                 RetransmitterEntry e = (RetransmitterEntry)msgs[index];
                 e.cancel();
             }
         }
         msgs.Clear();
     }
 }
예제 #2
0
 /// <summary> Reset the retransmitter: clear all msgs and cancel all the
 /// respective tasks
 /// </summary>
 public virtual void  reset()
 {
     lock (msgs.SyncRoot)
     {
         for (int index = 0; index < msgs.Count; index++)
         {
             RetransmitterEntry entry = (RetransmitterEntry)msgs[index];
             entry.cancel();
         }
         msgs.Clear();
     }
 }
예제 #3
0
        /// <summary> Add the given range [first_seqno, last_seqno] in the list of
        /// entries eligible for retransmission. If first_seqno > last_seqno,
        /// then the range [last_seqno, first_seqno] is added instead
        /// <p>
        /// If retransmitter thread is suspended, wake it up
        /// TODO:
        /// Does not check for duplicates !
        /// </summary>
        public virtual void  add(long first_seqno, long last_seqno)
        {
            RetransmitterEntry e;

            if (first_seqno > last_seqno)
            {
                long tmp = first_seqno;
                first_seqno = last_seqno;
                last_seqno  = tmp;
            }
            lock (msgs.SyncRoot)
            {
                e = new RetransmitterEntry(this, first_seqno, last_seqno, RETRANSMIT_TIMEOUTS);
                msgs.Add(e);
                retransmitter.AddTask(e);
            }
        }
예제 #4
0
 /// <summary> Remove the given sequence number from the list of seqnos eligible
 /// for retransmission. If there are no more seqno intervals in the
 /// respective entry, cancel the entry from the retransmission
 /// scheduler and remove it from the pending entries
 /// </summary>
 public virtual void  remove(long seqno)
 {
     lock (msgs.SyncRoot)
     {
         for (int index = 0; index < msgs.Count; index++)
         {
             RetransmitterEntry e = (RetransmitterEntry)msgs[index];
             lock (e)
             {
                 if (seqno < e.low || seqno > e.high)
                 {
                     continue;
                 }
                 e.remove(seqno);
                 if (e.low > e.high)
                 {
                     e.cancel();
                     msgs.RemoveAt(index);
                 }
             }
             break;
         }
     }
 }