mirror of
https://github.com/meshtastic/firmware.git
synced 2025-09-06 11:39:32 +00:00
Limitless queue + fuzzer = lots of ram :)
This commit is contained in:
parent
cf0e59d50d
commit
01417f6fd1
@ -74,11 +74,17 @@ template <class T> class TypedQueue
|
|||||||
{
|
{
|
||||||
std::queue<T> q;
|
std::queue<T> q;
|
||||||
concurrency::OSThread *reader = NULL;
|
concurrency::OSThread *reader = NULL;
|
||||||
|
int maxElements;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit TypedQueue(int maxElements) {}
|
explicit TypedQueue(int _maxElements) : maxElements(_maxElements) {}
|
||||||
|
|
||||||
int numFree() { return 1; } // Always claim 1 free, because we can grow to any size
|
int numFree()
|
||||||
|
{
|
||||||
|
if (maxElements <= 0)
|
||||||
|
return 1; // Always claim 1 free, because we can grow to any size
|
||||||
|
return maxElements - numUsed();
|
||||||
|
}
|
||||||
|
|
||||||
bool isEmpty() { return q.empty(); }
|
bool isEmpty() { return q.empty(); }
|
||||||
|
|
||||||
@ -86,6 +92,9 @@ template <class T> class TypedQueue
|
|||||||
|
|
||||||
bool enqueue(T x, TickType_t maxWait = portMAX_DELAY)
|
bool enqueue(T x, TickType_t maxWait = portMAX_DELAY)
|
||||||
{
|
{
|
||||||
|
if (numFree() <= 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (reader) {
|
if (reader) {
|
||||||
reader->setInterval(0);
|
reader->setInterval(0);
|
||||||
concurrency::mainDelay.interrupt();
|
concurrency::mainDelay.interrupt();
|
||||||
|
Loading…
Reference in New Issue
Block a user