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

Add a picture to Rc #2583

Merged
merged 1 commit into from
Jan 23, 2025
Merged

Add a picture to Rc #2583

merged 1 commit into from
Jan 23, 2025

Conversation

djmitche
Copy link
Collaborator

I suppose my svgbob skills leave a bit to be desired, but I think the meaning is clear:

image

Now that I look through the Rc implementation, there's a weak count for every strong count, so the weak: 0 here is inaccurate. But, maybe this is too much of an implementation detail? Should I just concentrate on strong refs? I suppose I could put a ... in that upper-right box, to suggest there's more going on here?

@djmitche djmitche requested a review from hurryabit January 22, 2025 11:24
Copy link
Collaborator

@hurryabit hurryabit left a comment

Choose a reason for hiding this comment

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

Very nice. Thank you.

: : : :
: +-----+ : : +-------------+-----------+ :
: a: | o---|---:-----:-->| strong: 2 | weak: 0 | :
: +-----+ : : +-------------+-----------+ :
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a way to use an "upside-down T" (or "bottom", as us logicians call it) at the lower end of the line separating the "strong" and "weak" cells?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea - that is an ugly cross! But I tweaked it a bit -- WDYT?

image

.- - - - - - - -. .- - - - - - - - - - - - - - - - -.
: : : :
: +-----+ : : +-------------+-----------+ :
: a: | o---|---:-----:-->| strong: 2 | weak: 0 | :
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not make it weak: 2 and say that every strong reference is also considered a weak reference. Or just leave this slight "lie". I don't think people taking this course need this level of detail to be correct.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just omitted the "weak" bit -- that can remain an implementation detail :)

@fw-immunant
Copy link
Collaborator

Thanks for this change--I was teaching this slide recently and wished I had a diagram instead of describing the memory layout of Rc only verbally.

Copy link
Collaborator

@hurryabit hurryabit left a comment

Choose a reason for hiding this comment

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

I think this is a good level of detail. Thank you.

@djmitche djmitche merged commit 9c03d51 into google:main Jan 23, 2025
35 checks passed
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.

3 participants