Expose SamplePtr age in C++ API#258
Conversation
|
Adding @darkwisebear and @bharatGoswami8 for input from Rust API side. |
fc8801e to
c5defba
Compare
castler
left a comment
There was a problem hiding this comment.
Thanks for your contribution.
I am the opinion that we should not expose this implementation detail - especially not the implementation data types.
We still want to give the opportuntity for a user to sort the samples.
Thus, we propose that the SamplePtr gets an bool IsNewer(SamplePtr<T> other) function instead.
|
Update: If I understood correctly, the intention is to avoid exposing EventTimeStamp (and related internals) and instead provide a way to compare samples without leaking those details. With that in mind, I’ve moved GetTimestamp() to a private helper (so it can still be reused internally if needed) and introduced IsNewer() as the public API for comparison. Unit tests were updated accordingly --> instead of checking timestamps directly, they now verify ordering by sorting SamplePtr instances using std::sort with IsNewer(). Let me know if this matches what you had in mind or if you'd prefer a different comparison approach. |
f567315 to
338c43f
Compare
338c43f to
d0ce09c
Compare
Update
|
Update
|
6ad242b to
a392c6e
Compare
1246105 to
a0db01f
Compare
|
Thanks for the feedback and the discussion so far. I revisited the implementation and reworked the approach based on the suggestions. Changes
Notes on testing (impl::SamplePtr)I did not introduce additional comparison tests for The current plumbing tests rely on Because of that:
I intentionally did not extend the mock binding in this PR to keep the scope focused. Additional notesI force-pushed the branch with only these changes to clean up the git history, but I do have a backup branch with the previous implementation in case that approach is preferred. |
a0db01f to
6174fd1
Compare
a62ae18 to
703d6a4
Compare
703d6a4 to
77aec48
Compare
UpdateAdded test in impl by implementing actual sampleptr instead of using generic mock pointer. |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If this PR is still relevant, please leave a comment or push new changes to keep it open. |
77aec48 to
eb7b917
Compare
|
Will there be more discussion in this PR or should I leave it be? |
|
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If this PR is still relevant, please leave a comment or push new changes to keep it open. |
|
Hi @Gfilinic, |
LittleHuba
left a comment
There was a problem hiding this comment.
Hi @Gfilinic,
your PR looks good now. It can be merged as it currently is.
Though, ideally I would like an immediate follow-up that provides the implementation of this API in the mock_binding. Otherwise we have an API that is not mockable...
Are you interested in working on that?
All remarks resolved.
Introduce operator< and operator> for comparing SamplePtr instances based on their timestamp. As part of this change, the previous approach of storing additional internal state for indirect access was removed. SamplePtr now stores only a local uint32_t timestamp value, which keeps the implementation simpler and reduces memory overhead. The operators return true only when both instances are valid and the comparison can be performed. In all other cases (e.g. invalid or default-constructed instances), false is returned.
add comparison operators (< and >) for SamplePtr with safe variant handling via std::visit
…r to match new signature
eb7b917 to
d8d7c1b
Compare
I’m interested in contributing to this project and started by looking into Issue #13.
Changes
GetTimestamp()function as requestedQuestions
Design question
For the default/null constructors, I currently initialize the internal state (
event_data_ctrl_ = nullptr, emptyslot_indicator_, etc.) so thatGetTimestamp()safely returns a default value.Does this align with the intended design, or would you prefer a different approach for representing an "invalid"
SamplePtr?I was advised to reach out to @crimson11 for this part of the code, as he likely has deeper insight into the design.