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

Redo reference counting #98

Draft
wants to merge 14 commits into
base: master
Choose a base branch
from
Draft

Conversation

madsmtm
Copy link

@madsmtm madsmtm commented May 29, 2021

My WIP on #95.

Adds Retained, a smart pointer version of StrongPtr, but with more guarantees. Notably, this has an Deref<Target = T> implementation, which makes it more ergonomic and safer to use.

Also adds Owned, the mutable version of Retained with a DerefMut<Target = T> implementation.

I'm thinking about removing StrongPtr completely in favour of this (since it's behaviour can be achieved with Retained<Object>), but please voice your opinion on this, and how we should handle backwards compatibility.

madsmtm added 3 commits May 31, 2021 08:33
See f52bc56, but that change made it very easy to create unbounded references, or create two aliasing mutable references.
The lifetime of the parameter is the lifetime of references in the pool. This allows us to bound lifetimes on autoreleased objects, thereby making them safe to return.
@madsmtm madsmtm force-pushed the smart-references branch from c5a7667 to 5846dd5 Compare May 31, 2021 08:09
@SSheldon
Copy link
Owner

SSheldon commented Aug 4, 2021

Like you mention in your comment here: #95 (comment)

I'd like to build this out-of-crate for now. objc-id was my attempt, and I'm not that happy with it. Perhaps you can build this in another crate first and prove it there?

@madsmtm
Copy link
Author

madsmtm commented Aug 6, 2021

Can you elaborate on what you were unhappy with in objc-id? Was the problem that it didn't work for cocoa, or something else?

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