01: // $Id: Interval.java,v 1.1.1.1 2003/09/09 01:24:12 belaban Exp $
02:
03: package org.jgroups.stack;
04:
05: /**
06: * Manages retransmission timeouts. Always returns the next timeout, until the last timeout in the
07: * array is reached. Returns the last timeout from then on, until reset() is called.
08: * @author John Giorgiadis
09: * @author Bela Ban
10: */
11: public class Interval {
12: private int next = 0;
13: private long[] interval = null;
14:
15: public Interval(long[] interval) {
16: if (interval.length == 0)
17: throw new IllegalArgumentException("Interval()");
18: this .interval = interval;
19: }
20:
21: public long first() {
22: return interval[0];
23: }
24:
25: /** @return the next interval */
26: public synchronized long next() {
27: if (next >= interval.length)
28: return (interval[interval.length - 1]);
29: else
30: return (interval[next++]);
31: }
32:
33: public long[] getInterval() {
34: return interval;
35: }
36:
37: public synchronized void reset() {
38: next = 0;
39: }
40: }
|