-
Notifications
You must be signed in to change notification settings - Fork 3k
CircularBuffer(): get available transactions #5058
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This implementation returns the number of available (stored) transactions in the buffer
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please align the code style.
The name available
or size()
? From boost circular buffer:
size_type size() const - Get the number of elements currently stored in the circular_buffer.
platform/CircularBuffer.h
Outdated
|
||
|
||
/** Returns the number of available transactions the buffer contains */ | ||
CounterType available() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please fix the code style : https://docs.mbed.com/docs/mbed-os-handbook/en/latest/cont/code_style/ (the file uses it as well, the only exception here is the body of the function :-) )
How is it supposed to improve efficiency ?
The buffer store elements not transactions and it would be better better to stick with the familiar C++ idiom |
@0x6d61726b bump |
@0x6d61726b bump. Is there any intention to progress this further? If not, can we close this? |
It allows to determine the number of used elements before processing them. I hope I made all the changes you intended me to do? |
Thanks for the changes. Could you provide an example (in code) showing how should be used to improve efficiency ? |
platform/CircularBuffer.h
Outdated
{ | ||
core_util_critical_section_enter(); | ||
CounterType elements; | ||
if (!_full) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use https://docs.mbed.com/docs/mbed-os-handbook/en/latest/cont/code_style/ (as it is in this file)
@pan- Happy with the new method? |
Happy with the name changes, however I would still like a code example demonstrating how it should be used to improve efficiency. |
retest uvisor |
@0x6d61726b could you please address @pan- comments? |
The example is about knowing the size of the buffer, so a following routine will not be triggered until the buffer contains a certain amount of expected data. The current implementation does not allow any knowledge about the stored amount of data in the buffer. |
Thank for the clarification. |
The last oustanding item for this patch is to align the our code style, plus would be good if the new method is tested (we are lacking the test for Circularbuffer, that shall be added, @fkjagodzinski @mprse for visiblity). |
@0x6d61726b Any update? |
I updated the code style. Hopefully it complies now, if not let me know whats wrong.
|
|
@mprse not yet, I'll create some more tasks soon. |
@0xc0170 Could you review? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than this one last change request, LGTM
platform/CircularBuffer.h
Outdated
if (_head < _tail) { | ||
elements = BufferSize + _head - _tail; | ||
} | ||
else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} else
on one line
@0x6d61726b Could you please address @0xc0170 review comment above ? |
@adbridge thanks for the reminder, I just did it. |
@0x6d61726b Thanks, LGTM, @0xc0170 can you please confirm you are happy with this now? |
/morph build |
Build : SUCCESSBuild number : 436 Triggering tests/morph test |
Test : FAILUREBuild number : 244 |
/morph test |
Test : SUCCESSBuild number : 272 |
/morph uvisor-test |
2 similar comments
/morph uvisor-test |
/morph uvisor-test |
Description
This implementation returns the number of available (stored) transactions in the buffer. It was introduced to improve efficiency.
Status
READY
Todos