Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
net_instaweb::CopyOnWrite< T > Class Template Reference

#include "copy_on_write.h"

Public Member Functions

 CopyOnWrite ()
 
 CopyOnWrite (const T &obj)
 
const T * get () const
 
const T * operator-> () const
 
const T & operator* () const
 
T * MakeWriteable ()
 
CopyOnWriteoperator= (const CopyOnWrite &src)
 
 CopyOnWrite (const CopyOnWrite &src)
 
void MergeOrShare (const CopyOnWrite &src)
 

Detailed Description

template<class T>
class net_instaweb::CopyOnWrite< T >

Implements a copy-on-write container. This is intended to be used to facilitate sharing of expensive-to-copy objects when most of the time we don't need to modify the copies.

T must be copyable and assignable. It does not need to be derived from any other class. It also must have an empty constructor and, if you want to use MergeOrShare, a Merge method.

Constructor & Destructor Documentation

template<class T>
net_instaweb::CopyOnWrite< T >::CopyOnWrite ( )
inline

Usage of default constructor requires that T also have a default constructor.

template<class T>
net_instaweb::CopyOnWrite< T >::CopyOnWrite ( const T &  obj)
inlineexplicit

Explicitly constructed CopyOnWrite pointers don't require T to have a default constructor.

Member Function Documentation

template<class T>
T* net_instaweb::CopyOnWrite< T >::MakeWriteable ( )
inline

Gets a unique mutable version of the object. This is not inherently thread-safe: if you call this from one thread while adding references from another thread, you will need to perform locking at a higher level.

template<class T>
void net_instaweb::CopyOnWrite< T >::MergeOrShare ( const CopyOnWrite< T > &  src)
inline

Merges in the contents of src into this. To increase speed and save memory, this method shares storage with src if this was empty.

If src is empty then the function is a no-op.

If this is empty, then we want to make it share src's storage.


The documentation for this class was generated from the following file: