version without weak pointers
Opened this issue · 1 comments
RiccardoRossi commented
Hello,
i was digging for "intrusive_ptr" implementations in the web and i found very promising your library.
What is the memory cost of each of your intrusive ptrs?
Your implementation gives the same thread safety guarantees as smart_ptrs, right?
On my side, i would be interested in using intrusive_ptrs instead of smart_ptr to reduce memory occupation of my program (as well as ideally to improve efficiency). For this reason i was looking for a lightweight version, without weak counters (i would use raw pointers instead of weak ones)
what would it take to achieve that?
lhmouse commented
在 2018/11/3 下午7:55, Riccardo Rossi 写道:
Hello,
i was digging for "intrusive_ptr" implementations in the web and i found
very promising your library.
Thank you for the approval.
What is the memory cost of each of your intrusive ptrs?
An `intrusive_ptr` has the same size as a `void *`.
As for `intrusive_base`, there is a reference counter having type
`atomic<long>` and a pointer to `_Weak_view`. Thus for each managed
object there is a memory overhead of two pointers typically.
Your implementation gives the same thread safety guarantees as
smart_ptrs, right?
The same with `std::shared_ptr` and `std::weak_ptr`, exactly.
On my side, i would be interested in using intrusive_ptrs instead of
smart_ptr to reduce memory occupation of my program (as well as ideally
to improve efficiency). For this reason i was looking for a lightweight
version, *without weak counters* (i would use raw pointers instead of
weak ones)
what would it take to achieve that?
See
<https://github.com/lhmouse/asteria/blob/master/asteria/src/rocket/refcounted_ptr.hpp>
for one without weak counters. There is still the atomic counter in each
managed object, but the pointer to `_Weak_view` whatsoever no longer
exists there.
…--
Best regards,
LH_Mouse