Page Speed Optimization Libraries
1.13.35.1
|
#include "manually_ref_counted.h"
Public Member Functions | |
void | IncrementRefs () |
void | DecrementRefs () |
Protected Member Functions | |
virtual | ~ManuallyRefCounted () |
Class that assists with manual reference counting. Other classes should inherit from this one, and users of those classes should call IncrementRefs when making copies and DecrementRefs when they finish with those copies.
|
inlineprotectedvirtual |
The destructor isn't public because instances of ManuallyRefCounted subclasses should not be directly deleted. They should be released via DecrementRefs().
|
inline |
Call this when finished with a pointer to a subclass instance: class ExampleHolder { Example* e; ~ExampleHolder() { if (e != NULL) { // If e is the last pointer to *e then *e will be deleted. e->DecrementRefs(); } } }
|
inline |
Call this when duplicating a pointer to subclass instances: Example* e = other->GetExample(); e->IncrementRefs();