Page Speed Optimization Libraries
1.13.35.1
|
#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 () |
CopyOnWrite & | operator= (const CopyOnWrite &src) |
CopyOnWrite (const CopyOnWrite &src) | |
void | MergeOrShare (const CopyOnWrite &src) |
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.
|
inline |
Usage of default constructor requires that T also have a default constructor.
|
inlineexplicit |
Explicitly constructed CopyOnWrite pointers don't require T to have a default constructor.
|
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.
|
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.