-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
fix: #3851 allow holder other than std::shared_ptr
to be used with class inherit from std::enable_shared_from_this
#5027
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Is it conceivable that someone out there is currently using a
holder_type
that needs this "variant 1"?(It's just that we don't have a corresponding unit test?)
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.
I'm not sure, but I don't think someone would use a custom holder type that expects to be constructed from a
std::shared_ptr<T>&&
rather than aT*
. If the custom holder type wraps astd::shared_ptr<T>
and utilizesstd::enable_shared_from_this
, it could callshared_from_this
manually in theT*
constructor.I apologize if I'm wrong. I'm not very familiar with this project and just happened to encounter the issue.
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.
I'm not sure, too. (That's not a great basis for making a decision about this PR.)
Looking in another direction, is it true that you need this PR to support your use case here?
https://github.com/openvinotoolkit/openvino/pull/22872/files#diff-5f0826fd3644f29a91bfbfa7f3a1b0be49edfc6a83ee022a798e25bc858f22f5
My reading of it:
ov::Model
to the lifetime ofov::CompiledModel
.Is that a correct interpretation?
If yes, that's a very unobvious and convoluted way to implement a lifetime dependency.
If
model
does indeed have to outlivecompiled_model
, the obvious solution would be to simply add a private member here and populate if from theicompiled_model
ctor (which already receives astd::shared_ptr<model>
):https://github.com/openvinotoolkit/openvino/blob/3986f55da28ee343780b623621d6b531a38af928/src/inference/dev_api/openvino/runtime/icompiled_model.hpp#L140
That will also ensure pure C++ code is memory-safer in general.
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.
Thanks for the advice. This is indeed a convoluted way to do that. I've figured out a way to solve that issue, and this PR would not need to be merged now. Should I close this PR?
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.
Sounds great! Yes, please close this PR if you no longer need it.