-
Notifications
You must be signed in to change notification settings - Fork 8
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
Nr 350676 changing handled exceptions to send one per request #338
base: develop
Are you sure you want to change the base?
Conversation
|
||
namespace NewRelic { | ||
namespace Hex { | ||
class HexReportContext : public HexContext { | ||
class HexReportContext : public HexContext, public std::enable_shared_from_this<HexReportContext> { |
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.
What does this line do?
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.
https://en.cppreference.com/w/cpp/memory/enable_shared_from_this
The std::enable_shared_from_this is used to safely obtain a std::shared_ptr to *this. This is what enables the ability to cast it as a HexContext and send it to the publisher.
HexReportContext::finalize() uses the shared_from_this() function to create a std::shared_ptr cast as a HexContext to send to publish.
This is the simplest patch to change handled exceptions to send one per request without rearchitecting.
We are planning to rewrite this code so this PR may not be necessary but open to input.