Page Speed Optimization Libraries
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Namespaces | Macros
ref_counted_ptr.h File Reference
#include "base/logging.h"
#include "pagespeed/kernel/base/atomic_int32.h"
#include "pagespeed/kernel/base/basictypes.h"

Go to the source code of this file.


class  net_instaweb::RefCounted< T >
class  net_instaweb::RefCountedPtr< T >
class  net_instaweb::RefCountedObj< T >
struct  net_instaweb::RefCountedObj< T >::Data


 Unit-test framework for wget fetcher.


#define REFCOUNT_FRIEND_DECLARATION(class_name)   friend class net_instaweb::RefCounted<class_name>

Detailed Description

Implements a generic ref-counted class, with full sharing. This class does not implement copy-on-write semantics, but it provides 'unique()', which helps implement COW at a higher level.

There are two pointer templates here:

TODO(jmaessen): explore adding C++x0 shared_ptr support

Macro Definition Documentation

#define REFCOUNT_FRIEND_DECLARATION (   class_name)    friend class net_instaweb::RefCounted<class_name>

Macro for users implementing C++ ref-counted classes to prevent explicit destruction. Once a class is reference counted, it should never be stack-allocated or explicitly deleted. It should only be deleted by the reference count object. Put this declaration in the 'protected:' or 'private:' section, and group it with a destructor declaration.

This is only required for RefCountedPtr<T>, not RefCountedObj<T>.