Review Board 2.0.15


[mq]: foo.diff

Review Request #436 - Created Jan. 21, 2011 and updated

Information
Nathan Binkert
gem5
Reviewers
Default
ali, gblack, nate, stever
This discussion of reference counting brings up an interesting issue that came up with a different project of mine.  That is constness.  Often people use Foo * and const Foo *, but as the class is currently written, we can't do that properly with our refcount stuff.  There are a few simple changes that do make this work (see diff).  The essential issue is that the reference count itself should be mutable, and the methods that access the actual pointer in the smart pointer class should be const (since you're not changing the smart pointer when you're accessing them).

Anyway, there's no rush or really even any need on my part for this, but in theory, we are doing it wrong and if people are trying to use "const FooPtr", they're probably doing the wrong thing.  I could just leave well enough alone and not touch this, or if people agree that what we have is wrong, I can make sure that this diff is correct run regressions, and commit it.

This would mean using two typedefs:
typedef RefCountingPtr<Foo> FooPtr;
typedef RefCountingPtr<const Foo> ConstFooPtr;