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

local_weak_ptr ? #58

Open
tower120 opened this issue Dec 14, 2018 · 2 comments
Open

local_weak_ptr ? #58

tower120 opened this issue Dec 14, 2018 · 2 comments

Comments

@tower120
Copy link

I do understand that local_shared_ptr <=> shared_ptr . And that local_shared_ptr is basically wrap shared_ptr.

But which "weak counter" use weak_ptr? Here:

   local_shared_ptr<X> px(new X());
   weak_ptr<X> wp(px);

local or atomic? From interface described in documentation - I suppose atomic. Because it's impossible to get local_shared_ptr directly from weak_ptr.

So... Is it possible to have local_weak_ptr?

@pdimov
Copy link
Member

pdimov commented Dec 14, 2018

No, it's not possible to have a local_weak_ptr. A local_shared_ptr may share ownership with a normal shared_ptr, or with another local_shared_ptr in a different thread. To properly keep track of ownership, the weak pointer has to be atomic.

@tower120
Copy link
Author

I see. Maybe there is need in non-convertible version of local_shared_ptr? Plus, I suppose non-convertible version would be more efficient... Something like unsync_shared_ptr / unsync_weak_ptr ?

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

No branches or pull requests

2 participants