Boost logo

Boost Users :

Subject: Re: [Boost-users] shared_ptr and global reset
From: Alexander (gutenev_at_[hidden])
Date: 2009-02-25 16:43:43


I am going to solve the same problem by replacing shared_ptr with a linked-list pointer. Each instance has pointers to two other so that all the instances pointing to the same object are linked in double linked loop. Size of such pointer is 3 times size of pointer (shared_ptr is only 2x pointer). This hardly can be done thread-safe without significant performance deradation. But it is easy to implement reset_all which changes all pointers that share the same ownership.

  Hi Boosters

  Let's say that I have many shared_ptr<A> sharing ownership to the same A object. At some point, I would like all those shared_ptr to point to a new Object A. Is there an easy (and safe) way to accomplish that?
  I know how to do that for one shared_ptr using either "reset", either operator = but in order to do this for all shared_ptr sharing ownership, the only way I could think of is through a registration mechanism (like the Observer pattern) but this sounds an overkilling process to me.

  So basically, is there a "global" reset method?



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net