|
Boost : |
Subject: Re: [boost] [shared_ptr] A smarter smart pointer proposal for dynamic libraries
From: J.D. Herron (jotadehace_at_[hidden])
Date: 2008-12-24 02:27:52
Yes that's the point, its inlined wherever the shared pointer template is
instantiated for the type. Being a template it has to work that way. Since
that code is the same whether its instantiated in the unloaded dll or the
executable, everything works.
Your solution is fine except it demands an extra burden on the architecture
that in my opinion is unnecessary. The shared_ptr should behave as much
like a raw pointer as possible and this would be another step closer to
that. Also, we have use cases that need to unload factories but what they
produced could still be floating around the system.
J.D.
On Tue, Dec 23, 2008 at 9:37 PM, Emil Dotchevski
<emildotchevski_at_[hidden]>wrote:
> As far as I can tell, the only reason your reset() appears to work is
> that it is inlined in the executable. The compiler doesn't guarantee
> inlining, so in general it will crash anyway.
>
> The solution to this problem is to inject the DLL's lifetime into any
> shared_ptrs obtained from that DLL; that is, make the shared_ptr keep
> the DLL afloat. This can be done easily (and non-intrusively) using
> shared_ptr's aliasing constructor.
>
> Emil Dotchevski
> Reverge Studios, Inc.
> http://www.revergestudios.com/reblog/index.php?n=ReCode
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk