Skip to content

Commit 8696075

Browse files
committed
PROPOSAL: discard oldest value if the queue is full
Also fixes @aentinger comment about return types
1 parent f5235ce commit 8696075

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Arduino_Threads.h

+5
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,14 @@ class Shared // template definition
1414
}
1515
}
1616
T& operator= (const T& other) {
17+
if (queue->full()) {
18+
// invokes operator T()
19+
T discard = *this;
20+
}
1721
val = other;
1822
T* obj = new T(val);
1923
queue->put(obj);
24+
return (*obj);
2025
}
2126
T& peek() {
2227
return val;

0 commit comments

Comments
 (0)