hpcc-systems/HPCC-Platform — pull request #1058 by ghalliday (2011-11-24 08:15:07+00:00)
Title: Rationalize the Owned/Linked classes

This change is designed to make it easier to understand the smart
pointer objects used to support the link release model. I have
created a new Shared<> template class which is the base class for the
Owned<> and Linked<> classes.
The Shared<> class is similar to a boost intrusive_ptr, and is an STL
compatible object which holds a reference to a linked object or
interface. You can pass and return Shared objects, and not need to
ever call Link/Release/set/setown.

However Shared contains no methods for constructing a Shared from a
pointer, or assigning a pointer to a Shared. This needs to be done
explicitly using the Linked and Owned clasess. This means that it
is explicit whether you are taking ownership of the object or not.
(Boost uses an extra parameter which may reduce link/releases in a few
situations, but is much less clear).

To avoid any leaks using Shared pointer:
* Any function that takes an owned pointer should take a shared
* Any function that returns a linked pointer should return a shared
* Any function that takes a reference to a smart pointer - so it can be
updated in place, should use a type Shared.
* Owned/Linked should only be used when initializing a shared pointer
from a pointer. Shared should be used from another Shared.

Signed-off-by: Gavin Halliday