Page Speed Optimization Libraries
1.5.27.2
|
#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.
virtual net_instaweb::ManuallyRefCounted::~ManuallyRefCounted | ( | ) | [inline, protected, virtual] |
The destructor isn't public because instances of ManuallyRefCounted subclasses should not be directly deleted. They should be released via DecrementRefs().
void net_instaweb::ManuallyRefCounted::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(); } } }
void net_instaweb::ManuallyRefCounted::IncrementRefs | ( | ) | [inline] |
Call this when duplicating a pointer to subclass instances: Example* e = other->GetExample(); e->IncrementRefs();