by cdelmas » 09 Aug 2007, 15:39
> Is it planned to add support to weak pointers to Poco ?
A "weak pointer" is a reference object (same kind as SharedPtr) but doens't have any responsibility about resource management.
A resource held by a SharedPtr is freed when reference count falls to 0. If this resource is also held by a WeakPtr, it is freed even if there are many WeakPtr pointing to it.
WeakPtr may not define -> and * operators, and may only return a SharedPtr (or a SharedPtr may be constructed from a WeakPtr) to the pointed object, or SharedPtr(0) if the resource has been cleaned.
For this to work, the count may be implemented as a pointer to an object (ReferenceCounter ?).
Thank you for your answers and suggestions.