Re: [glas] Reference counting?
From: Karl Meerbergen (Karl.Meerbergen_at_[hidden])
Date: 2007-10-12 09:36:52
This is the idea of a boost::shared_ptr.
It is clear that this might help in some cases for improving reliability
If I understand Neal well, the situation could be the following:
you create a matrix.
Later, you create an object that is a proxy to a row of this matrix.
If you have reference counting, the programmer can destroy the matrix
before the row proxy. Without the reference count, the proxy should be
destroyed before the matrix.
At this stage, this mechanism is indeed not provided. In practice, it
would imply adding a boost::shared_ptr in all containers. This is
possible, but could it not create undesired overhead?
One of the great things of generic programming is that we can provide
containers and proxies that support reference counting in addition to
containers and proxies that do not use reference counting :-)
Bert Rodiers wrote:
> Hello Karl,
> An example:
> You have a class CVec, the data is stored in seperate class CView to
> which CVec points. CView also has a reference count. At the moment you
> create a CVec a CView is recreated with reference count 1, when a new
> CVec is created from an existing one, the CView is being shared and
> the reference count is increased (with a function call). When a CVec
> is destroyed, you decrease the reference count (with a function call)
> and when the reference count becomes zero you destroy the object.
> I could point you to books that discuss reference counting in more
> On 12/10/2007, *Karl Meerbergen* < Karl.Meerbergen_at_[hidden]
> <mailto:Karl.Meerbergen_at_[hidden]>> wrote:
> Hi Neal,
> I have not thought of this. I am a bit puzzled. Can you explain
> what you
> mean by reference counting? Do you mean that a container will only
> disappear when all its references by other objects disappear?
> Neal Becker wrote:
> >I'm looking at the glas alpha docs. I've been studying blitz++
> recently, and
> >I have (so far) liked the use of reference counting.
> >A slice of an array returns a (shared) view of the array
> data. Reference
> >counting is used for memory management.
> >I read the comments in glas regarding assignment vs. copy
> construction. Have
> >you considered using ref counting instead?
> >glas mailing list
> > glas_at_[hidden] <mailto:glas_at_[hidden]>
> > http://lists.boost.org/mailman/listinfo.cgi/glas
> glas mailing list
> glas_at_[hidden] <mailto:glas_at_[hidden]>
>glas mailing list