Repository navigation
[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.
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]>
…_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: Future-Outlier <[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.