4 * Circular buffer that holds the live set of slots.
10 static final int DEFAULT_SIZE = 128;
15 public long oldestseqn;
18 array = new Slot[DEFAULT_SIZE + 1];
26 return (array.length + head) - tail;
30 return array.length - 1;
33 void resize(int newsize) {
34 if (newsize == (array.length - 1))
37 Slot[] newarray = new Slot[newsize + 1];
38 int currsize = size();
40 for (int i = 0; i < currsize; i++) {
41 newarray[i] = array[index];
42 if ((++index) == array.length)
50 private void incrementHead() {
52 if (head >= array.length)
56 private void incrementTail() {
58 if (tail >= array.length)
62 void putSlot(Slot s) {
64 long checkNum = (getNewestSeqNum() + 1);
66 if (checkNum != s.getSequenceNumber()) {
67 // We have a gap so expunge all our slots
68 oldestseqn = s.getSequenceNumber();
78 if (oldestseqn == 0) {
79 oldestseqn = s.getSequenceNumber();
88 Slot getSlot(long seqnum) {
89 int diff = (int) (seqnum - oldestseqn);
90 int index = diff + tail;
93 // Really old message so we dont have it anymore
97 if (index >= array.length) {
101 index -= array.length;
104 if (index >= array.length) {
108 if (head >= tail && index >= head) {
115 long getOldestSeqNum() {
119 long getNewestSeqNum() {
120 return oldestseqn + size() - 1;