/// <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(); } }
/// <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(); } }
/// <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; } } }