No, my idea was not to share the same RefCountingPtr. I was trying to share the pointer to an object reference to which are being counted. If you take a look at the patches that I have posted on the m5 review board, I am trying to use the same RubyRequest object in multiple places. The class RubyRequest is reference counted and I was trying to make sure that the multiple pointers to same object of this class are handled correctly.

--
Nilay

On Fri, 21 Jan 2011, Jeroen De Wachter wrote:

I get the feeling you are asking about using the same RefCountingPtr
instance in multiple places: don't do that. It will only complicate
matters.

Just copy the RefCountingPtr, like you would copy a standard pointer.
The copy constructor and destructor in RefCountingPtr will make sure
it's handled properly, so you don't have to worry about it.

If you'd like more documentation on this, Qt provides very similar
functionality with the QSharedPointer class:
http://doc.trolltech.com/4.6/qsharedpointer.html#details
Qt also has a number of other Pointer-replacing classes that are all
slightly different. Reading about those might be interesting, too

Grts,

Jeroen

On Thu, 2011-01-20 at 12:28 -0600, Nilay Vaish wrote:
So how would you handle pointer to an object which is reference counted?
Pointer to the same object may be being used at multiple places.

I am facing some trouble with this. Should I post the code on the review
board?

Nilay

On Thu, 20 Jan 2011, nathan binkert wrote:

What's the need of having reference counting? And more specifically, why do
we need message going into ruby to be reference counted?

Reference counting is a garbage collection strategy.  It also happens
to be one that is easily used in C++.  The specific reason why we use
reference counting in a few places is because it can some times be
difficult to keep track of an object and know when to delete it.  For
example, if you fire off a message into the memory system, who is
responsible for deleting it?  There are many different paths that a
message could take and potentially many different endpoints where a
message could be finished.  With reference counting, when the last
reference is given up, the object is automatically destroyed.  For
more info, I suggest wikipedia or google.

 Nate
_______________________________________________
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev

_______________________________________________
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev


_______________________________________________
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev

_______________________________________________
m5-dev mailing list
m5-dev@m5sim.org
http://m5sim.org/mailman/listinfo/m5-dev

Reply via email to