projects
/
iotcloud.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
edits
[iotcloud.git]
/
version2
/
src
/
C
/
SlotBuffer.cc
diff --git
a/version2/src/C/SlotBuffer.cc
b/version2/src/C/SlotBuffer.cc
index 4ddf4ba3c7b0c4d12c3ac519f7a12b4118d487d4..248abd78017f03237e0f74cd8cf5bfc8403ad962 100644
(file)
--- a/
version2/src/C/SlotBuffer.cc
+++ b/
version2/src/C/SlotBuffer.cc
@@
-1,4
+1,5
@@
#include "SlotBuffer.h"
#include "SlotBuffer.h"
+#include "Slot.h"
/**
* Circular buffer that holds the live set of slots.
* @author Brian Demsky
/**
* Circular buffer that holds the live set of slots.
* @author Brian Demsky
@@
-12,6
+13,10
@@
SlotBuffer::SlotBuffer() :
oldestseqn(0) {
}
oldestseqn(0) {
}
+SlotBuffer::~SlotBuffer() {
+ delete array;
+}
+
int SlotBuffer::size() {
if (head >= tail)
return head - tail;
int SlotBuffer::size() {
if (head >= tail)
return head - tail;
@@
-55,7
+60,6
@@
void SlotBuffer::putSlot(Slot *s) {
int64_t checkNum = (getNewestSeqNum() + 1);
if (checkNum != s->getSequenceNumber()) {
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;
oldestseqn = s->getSequenceNumber();
tail = 0;
head = 1;
@@
-76,12
+80,11
@@
void SlotBuffer::putSlot(Slot *s) {
}
}
}
}
-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) {
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;
}
return NULL;
}
@@
-92,10
+95,10
@@
Slot SlotBuffer::getSlot(int64_t seqnum) {
index -= array->length();
}
index -= array->length();
}
- if (index >= array->length) {
-
+ if (index >= array->length()) {
return NULL;
}
return NULL;
}
+
if (head >= tail && index >= head) {
return NULL;
}
if (head >= tail && index >= head) {
return NULL;
}