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

Peek API to view data of buffer without popping #6309

Merged
merged 2 commits into from Mar 22, 2018

Conversation

Projects
None yet
5 participants
@deepikabhavnani
Contributor

deepikabhavnani commented Mar 8, 2018

Description

Added peek API to view data of CircularBuffer without popping.

Pull request type

  • Fix
  • Refactor
  • New target
  • Feature
  • Breaking change
@geky

This comment has been minimized.

Member

geky commented Mar 8, 2018

I believe this falls under "feature"

Does the Circular Buffer have tests? Could we add a test covering this function?

* @param data Data to be peeked from the buffer
* @return True if the buffer is not empty and data contains a transaction, false otherwise
*/
bool peek(T& data) const {

This comment has been minimized.

@geky

geky Mar 8, 2018

Member

Hmm, does data need to be const if peek is a const member function?

This comment has been minimized.

@deepikabhavnani

deepikabhavnani Mar 9, 2018

Contributor

const member function is not allowed to modify the object elements, which is not done in case of this API. But we are passing data as return value hence it cannot be const.

This comment has been minimized.

@geky

geky Mar 9, 2018

Member

That would be an issue if it was a const reference (T& const data). But since it's a reference-to-const (const T& data), it should be fine.

Does this compile as is with a const CircularBuffer?

This comment has been minimized.

@deepikabhavnani

deepikabhavnani Mar 13, 2018

Contributor

Not all members of CircularBuffer are const, without this API also it won't compile as const CircularBuffer.

(const T& data) in case of template class says value of data variable cannot be modified in the function. We are passing the data value, hence it cannot be const. I tried compilation with const and it failed.

This comment has been minimized.

@geky

geky Mar 21, 2018

Member

Oh, that's annoying if there's a similar issue in other functions.

const T& data can be assigned with issue.

@cmonr

cmonr approved these changes Mar 21, 2018

LGTM

@cmonr

This comment has been minimized.

Contributor

cmonr commented Mar 21, 2018

/morph build

@mbed-ci

This comment has been minimized.

mbed-ci commented Mar 21, 2018

Build : SUCCESS

Build number : 1503
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/6309/

Triggering tests

/morph test
/morph uvisor-test
/morph export-build
/morph mbed2-build

@mbed-ci

This comment has been minimized.

@mbed-ci

This comment has been minimized.

@0xc0170

This comment has been minimized.

Member

0xc0170 commented Mar 21, 2018

/morph export-build

@mbed-ci

This comment has been minimized.

@cmonr cmonr added ready for merge and removed needs: review labels Mar 21, 2018

@cmonr cmonr merged commit 9932b4c into ARMmbed:master Mar 22, 2018

19 checks passed

AWS-CI uVisor Build & Test Success
Details
ci-morph-build build completed
Details
ci-morph-exporter build completed
Details
ci-morph-mbed2-build build completed
Details
ci-morph-test test completed
Details
continuous-integration/jenkins/pr-head This commit looks good
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
travis-ci/docs Local docs testing has passed
Details
travis-ci/events Local events testing has passed
Details
travis-ci/littlefs Passed, code size is 10060B (+0.00%)
Details
travis-ci/mbed2-ATMEL Local mbed2-ATMEL testing has passed
Details
travis-ci/mbed2-MAXIM Local mbed2-MAXIM testing has passed
Details
travis-ci/mbed2-NORDIC Local mbed2-NORDIC testing has passed
Details
travis-ci/mbed2-NUVOTON Local mbed2-NUVOTON testing has passed
Details
travis-ci/mbed2-NXP Local mbed2-NXP testing has passed
Details
travis-ci/mbed2-RENESAS Local mbed2-RENESAS testing has passed
Details
travis-ci/mbed2-SILICON_LABS Local mbed2-SILICON_LABS testing has passed
Details
travis-ci/mbed2-STM Local mbed2-STM testing has passed
Details
travis-ci/tools Local tools testing has passed
Details

@cmonr cmonr removed the ready for merge label Mar 22, 2018

@deepikabhavnani deepikabhavnani deleted the deepikabhavnani:peek_api branch Mar 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment