#include "SlotBuffer.h"
+#include "Slot.h"
/**
* Circular buffer that holds the live set of slots.
* @author Brian Demsky
oldestseqn(0) {
}
+SlotBuffer::~SlotBuffer() {
+ delete array;
+}
+
int SlotBuffer::size() {
if (head >= tail)
return head - tail;
int64_t checkNum = (getNewestSeqNum() + 1);
if (checkNum != s->getSequenceNumber()) {
- // We have a gap so expunge all our slots
oldestseqn = s->getSequenceNumber();
tail = 0;
head = 1;
}
}
-Slot SlotBuffer::getSlot(int64_t seqnum) {
+Slot *SlotBuffer::getSlot(int64_t seqnum) {
int32_t diff = (int32_t) (seqnum - oldestseqn);
int32_t index = diff + tail;
if (index < 0) {
- // Really old message so we dont have it anymore
return NULL;
}
index -= array->length();
}
- if (index >= array->length) {
-
+ if (index >= array->length()) {
return NULL;
}
+
if (head >= tail && index >= head) {
return NULL;
}