-
Notifications
You must be signed in to change notification settings - Fork 178
Add documentation for shared pointer class #671
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
Conversation
@jen3andruska Could you please copy edit this file when you get a chance? |
@AnotherButler No problem! |
@AnotherButler Finished copy-editing and made revisions. |
Fix spacing in SharedPtr.md
@jen3andruska Thanks for the CE. It looks great 👍 |
|
||
When `ptr` is passed around by a value, the copy constructor and destructor manage the reference count of the raw pointer. If the counter reaches zero, `delete` is called on the raw pointer. | ||
|
||
To avoid loops, use "weak" references by calling the original pointer directly with `ptr.get()`. |
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 would remove that sentence as it is misleading and can lead to access of a dangling pointer as it is not possible to know if a pointer acquired previously with ptr.get()
is valid or not.
@AnotherButler No Problem 👍 |
Thanks @jen3andruska @pan- @AnotherButler |
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.
A couple of nits. Take 'em or leave 'em.
@@ -0,0 +1,34 @@ | |||
## Shared Pointer | |||
|
|||
A shared pointer is a "smart" pointer that retains ownership of an object by using reference counting accross all smart pointers referencing that object. |
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.
Could it be clarified what that
is suppose to mean in this sentence?
|
||
Usage: `SharedPtr<Class> ptr(new Class())` | ||
|
||
When `ptr` is passed around by a value, the copy constructor and destructor manage the reference count of the raw pointer. If the counter reaches zero, `delete` is called on the raw pointer. |
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.
s/manage/manages
@pan- Mind re-reviewing? Looks like GitHub didn't catch the update (for some reason) |
ping @pan- |
This is the associated documentation PR for ARMmbed/mbed-os#7815.