Skip to content

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

Merged
merged 6 commits into from
Aug 29, 2018

Conversation

donatieng
Copy link
Contributor

This is the associated documentation PR for ARMmbed/mbed-os#7815.

@AnotherButler
Copy link
Contributor

@jen3andruska Could you please copy edit this file when you get a chance?

@jen3andruska
Copy link
Contributor

@AnotherButler No problem!

@jen3andruska
Copy link
Contributor

@AnotherButler Finished copy-editing and made revisions.

Fix spacing in SharedPtr.md
@AnotherButler
Copy link
Contributor

@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()`.
Copy link
Member

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.

@jen3andruska
Copy link
Contributor

@AnotherButler No Problem 👍

@donatieng
Copy link
Contributor Author

Thanks @jen3andruska @pan- @AnotherButler

Copy link
Contributor

@cmonr cmonr left a 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.
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

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

s/manage/manages

@cmonr
Copy link
Contributor

cmonr commented Aug 28, 2018

@pan- Mind re-reviewing? Looks like GitHub didn't catch the update (for some reason)

@AnotherButler
Copy link
Contributor

FYI @MarceloSalazar @ashok-rao

@AnotherButler
Copy link
Contributor

ping @pan-

@AnotherButler AnotherButler merged commit d0a5393 into ARMmbed:development Aug 29, 2018
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.

5 participants