RE: Application crash but when I swap lines it works.
- From: "Gavin Lambert" <gavinl compacsort com>
- To: "'Oscar Lazzarino'" <oscar lazzarino i-m3d com>, <gtkmm-list gnome org>
- Subject: RE: Application crash but when I swap lines it works.
- Date: Tue, 13 Mar 2012 10:59:18 +1300
Quoth Oscar Lazzarino:
> Just guessing, but I don't think passing a boost::shared_ptr by const
> reference is a good idea. Just pass it by value.
Passing a boost::shared_ptr as a parameter by const reference is a *very*
good idea -- if you don't do this then you're needlessly copying it, and
copies are expensive (requires multiple interlocked operations).
It only becomes a potential concern in a multithreaded environment, and even
then only if you're mixing read/write operations on the same instance across
multiple threads (eg. from a member field). But that's not special to
shared_ptr, most data structures will require additional locks if you're
doing that sort of thing. And providing proper "get" methods that return
the shared_ptr by value (from within the appropriate lock) will mitigate
much of those sorts of problems too.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]