Skip to content
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

src: make nsolid::ThreadMetrics safer #37

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

santigimeno
Copy link
Member

@santigimeno santigimeno commented Nov 29, 2023

The current ThreadMetrics API is not easy to use safely because the ThreadMetrics instance needs to be alive while there is a pending Update() callback to be called. Change the API to use shared_ptr, as we define a new type SharedThreadMetrics as
std::shared_ptr<ThreadMetrics>.
This is a breaking change but considering previous API was completely
unsafe and apparently there're still no consumers I think is a good
change.

@santigimeno santigimeno self-assigned this Nov 29, 2023
@santigimeno santigimeno force-pushed the santi/fix_thread_metrics branch 2 times, most recently from 601cc15 to 8f5c66a Compare December 5, 2023 09:15
@santigimeno santigimeno marked this pull request as ready for review December 5, 2023 09:15
@santigimeno santigimeno changed the title [RFC] src: make nsolid::ThreadMetrics safer src: make nsolid::ThreadMetrics safer Dec 5, 2023
@santigimeno santigimeno force-pushed the santi/fix_thread_metrics branch 2 times, most recently from d41c671 to 0246a12 Compare December 11, 2023 20:40
Copy link
Member

@trevnorris trevnorris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doing it this way has grown on me. Great change. Please address the comments I left before merging.

src/nsolid.cc Outdated Show resolved Hide resolved
src/nsolid.cc Outdated Show resolved Hide resolved
src/nsolid.h Outdated Show resolved Hide resolved
src/nsolid.h Outdated Show resolved Hide resolved
The current ThreadMetrics API is not easy to use safely because the
`ThreadMetrics` instance needs to be alive while there is a pending
`Update()` callback to be called. Change the API to use shared_ptr, as
we define a new type `SharedThreadMetrics` as
`std::shared_ptr<ThreadMetrics>`.
This is a breaking change but considering previous API was completely
unsafe and apparently there're still no consumers I think is a good
change.

PR-URL: #37
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
@santigimeno santigimeno merged commit a218600 into node-v20.x-nsolid-v5.x Dec 13, 2023
16 of 18 checks passed
@santigimeno santigimeno deleted the santi/fix_thread_metrics branch December 13, 2023 22:40
trevnorris pushed a commit that referenced this pull request Dec 19, 2023
The current ThreadMetrics API is not easy to use safely because the
`ThreadMetrics` instance needs to be alive while there is a pending
`Update()` callback to be called. Change the API to use shared_ptr, as
we define a new type `SharedThreadMetrics` as
`std::shared_ptr<ThreadMetrics>`.
This is a breaking change but considering previous API was completely
unsafe and apparently there're still no consumers I think is a good
change.

PR-URL: #37
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
trevnorris pushed a commit that referenced this pull request Dec 19, 2023
The current ThreadMetrics API is not easy to use safely because the
`ThreadMetrics` instance needs to be alive while there is a pending
`Update()` callback to be called. Change the API to use shared_ptr, as
we define a new type `SharedThreadMetrics` as
`std::shared_ptr<ThreadMetrics>`.
This is a breaking change but considering previous API was completely
unsafe and apparently there're still no consumers I think is a good
change.

PR-URL: #37
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants