diff options
author | David Crocker <dcrocker@eschertech.com> | 2021-09-09 14:47:45 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2021-09-09 14:47:45 +0300 |
commit | 4191a4c83df2cb7fa80ed2d97ec84f43bdac56bd (patch) | |
tree | 1e64149261e270f25f6689471e10a8f823a63c6a /src | |
parent | 7d449836123f59ef1c587cd981a88ea7c63518ac (diff) |
Removed use of 'friend' in class OutputBuffer
Diffstat (limited to 'src')
-rw-r--r-- | src/Platform/OutputMemory.cpp | 13 | ||||
-rw-r--r-- | src/Platform/OutputMemory.h | 9 |
2 files changed, 13 insertions, 9 deletions
diff --git a/src/Platform/OutputMemory.cpp b/src/Platform/OutputMemory.cpp index 2ef4329d..39ffda41 100644 --- a/src/Platform/OutputMemory.cpp +++ b/src/Platform/OutputMemory.cpp @@ -105,6 +105,11 @@ void OutputBuffer::Clear() noexcept dataLength = 0; } +void OutputBuffer::UpdateWhenQueued() noexcept +{ + whenQueued = millis(); +} + size_t OutputBuffer::vprintf(const char *fmt, va_list vargs) noexcept { Clear(); @@ -378,7 +383,7 @@ bool OutputBuffer::WriteToFile(FileData& f) const noexcept buf->references = 1; // assume it's only used once by default buf->isReferenced = false; buf->hadOverflow = false; - buf->whenQueued = millis(); // use the time of allocation as the default when-used time + buf->UpdateWhenQueued(); // use the time of allocation as the default when-used time return true; } @@ -489,7 +494,7 @@ bool OutputStack::Push(OutputBuffer *buffer, MessageType type) volatile noexcept { if (buffer != nullptr) { - buffer->whenQueued = millis(); + buffer->UpdateWhenQueued(); } items[count] = buffer; types[count] = type; @@ -549,7 +554,7 @@ void OutputStack::SetFirstItem(OutputBuffer *buffer) volatile noexcept else { items[0] = buffer; - buffer->whenQueued = millis(); + buffer->UpdateWhenQueued(); } } } @@ -580,7 +585,7 @@ bool OutputStack::ApplyTimeout(uint32_t ticks) volatile noexcept if (count != 0) { OutputBuffer * buf = items[0]; // capture volatile variable - while (buf != nullptr && millis() - buf->whenQueued >= ticks) + while (buf != nullptr && millis() - buf->WhenQueued() >= ticks) { items[0] = buf = OutputBuffer::Release(buf); ret = true; diff --git a/src/Platform/OutputMemory.h b/src/Platform/OutputMemory.h index 831febe2..3b15855c 100644 --- a/src/Platform/OutputMemory.h +++ b/src/Platform/OutputMemory.h @@ -17,14 +17,10 @@ const size_t OUTPUT_STACK_DEPTH = 64; // Number of OutputBuffer chains that can const size_t OUTPUT_STACK_DEPTH = 4; // Number of OutputBuffer chains that can be pushed onto one stack instance #endif -class OutputStack; - // This class is used to hold data for sending (either for Serial or Network destinations) class OutputBuffer { public: - friend class OutputStack; - OutputBuffer(OutputBuffer *n) noexcept : next(n) { } OutputBuffer(const OutputBuffer&) = delete; @@ -45,6 +41,9 @@ public: void Taken(size_t len) noexcept { bytesRead += len; } size_t BytesLeft() const noexcept { return dataLength - bytesRead; } // How many bytes have not been sent yet? + uint32_t WhenQueued() const noexcept { return whenQueued; } + void UpdateWhenQueued() noexcept; + size_t vprintf(const char *fmt, va_list vargs) noexcept; size_t printf(const char *fmt, ...) noexcept __attribute__ ((format (printf, 2, 3))); size_t vcatf(const char *fmt, va_list vargs) noexcept; @@ -100,7 +99,7 @@ private: OutputBuffer *next; OutputBuffer *last; - uint32_t whenQueued; + uint32_t whenQueued; // milliseconds timer when this buffer was filled in char data[OUTPUT_BUFFER_SIZE]; size_t dataLength, bytesRead; |