-
Notifications
You must be signed in to change notification settings - Fork 7k
[core] Use shared_ptr for pins_in_flight_ instead of shared_from_this
#58744
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
[core] Use shared_ptr for pins_in_flight_ instead of shared_from_this
#58744
Conversation
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
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.
Code Review
This pull request correctly refactors RayletClient to remove the dependency on std::enable_shared_from_this. By converting pins_in_flight_ to a std::shared_ptr<std::atomic<int64_t>>, you've effectively decoupled the lifetime of the counter from the RayletClient instance, allowing it to be safely used in asynchronous callbacks without requiring the client object to be managed by a shared_ptr. The implementation is clean and achieves the intended goal. I have one minor suggestion to improve the clarity of a lambda capture.
|
@dayshah any clever C++ magic you have up your sleeve that could be used to ban people from unknowingly capturing |
Signed-off-by: Edward Oakes <[email protected]>
Signed-off-by: Edward Oakes <[email protected]>
eh, you could have a wrapper class to create the callbacks, and the constructor could not take pointers and references. But imo not worth it... |
…_this` (ray-project#58744) While writing the [follow up](https://github.com/ray-project/ray/pull/58660/files#r2538761540) to ban stack-allocated `RayletClient` instances, @dayshah proposed a simpler solution: make the counter a shared_ptr instead of capturing the entire class. --------- Signed-off-by: Edward Oakes <[email protected]>
Cherry picks two changes: - #58660 - #58744 --------- Signed-off-by: dragongu <[email protected]> Signed-off-by: Edward Oakes <[email protected]> Co-authored-by: dragongu <[email protected]> Co-authored-by: gulonglong <[email protected]>
…_this` (ray-project#58744) While writing the [follow up](https://github.com/ray-project/ray/pull/58660/files#r2538761540) to ban stack-allocated `RayletClient` instances, @dayshah proposed a simpler solution: make the counter a shared_ptr instead of capturing the entire class. --------- Signed-off-by: Edward Oakes <[email protected]> Signed-off-by: Aydin Abiar <[email protected]>
…_this` (ray-project#58744) While writing the [follow up](https://github.com/ray-project/ray/pull/58660/files#r2538761540) to ban stack-allocated `RayletClient` instances, @dayshah proposed a simpler solution: make the counter a shared_ptr instead of capturing the entire class. --------- Signed-off-by: Edward Oakes <[email protected]>
…_this` (ray-project#58744) While writing the [follow up](https://github.com/ray-project/ray/pull/58660/files#r2538761540) to ban stack-allocated `RayletClient` instances, @dayshah proposed a simpler solution: make the counter a shared_ptr instead of capturing the entire class. --------- Signed-off-by: Edward Oakes <[email protected]> Signed-off-by: YK <[email protected]>
…_this` (ray-project#58744) While writing the [follow up](https://github.com/ray-project/ray/pull/58660/files#r2538761540) to ban stack-allocated `RayletClient` instances, @dayshah proposed a simpler solution: make the counter a shared_ptr instead of capturing the entire class. --------- Signed-off-by: Edward Oakes <[email protected]>
While writing the follow up to ban stack-allocated
RayletClientinstances, @dayshah proposed a simpler solution: make the counter a shared_ptr instead of capturing the entire class.