3 * Circular buffer that holds the live set of slots.
9 static final int DEFAULT_SIZE = 16;
17 array = new Slot[DEFAULT_SIZE + 1];
25 return (array.length + head) - tail;
29 return array.length - 1;
32 void resize(int newsize) {
33 if (newsize == (array.length - 1))
36 Slot[] newarray = new Slot[newsize + 1];
37 int currsize = size();
39 for (int i = 0; i < currsize; i++) {
40 newarray[i] = array[index];
41 if ((++index) == array.length)
49 void incrementHead() {
51 if (head >= array.length)
55 void incrementTail() {
57 if (tail >= array.length)
61 void putSlot(Slot s) {
63 int64_t checkNum = (getNewestSeqNum() + 1);
65 if (checkNum != s.getSequenceNumber()) {
66 // We have a gap so expunge all our slots
67 oldestseqn = s.getSequenceNumber();
77 if (oldestseqn == 0) {
78 oldestseqn = s.getSequenceNumber();
87 Slot getSlot(int64_t seqnum) {
88 int diff = (int) (seqnum - oldestseqn);
89 int index = diff + tail;
92 // Really old message so we dont have it anymore
96 if (index >= array.length) {
100 index -= array.length;
103 if (index >= array.length) {
107 if (head >= tail && index >= head) {
114 int64_t getOldestSeqNum() {
118 int64_t getNewestSeqNum() {
119 return oldestseqn + size() - 1;