class Arena
Defined at line 169 of file ../../third_party/protobuf/src/google/protobuf/arena.h
Arena allocator. Arena allocation replaces ordinary (heap-based) allocation
with new/delete, and improves performance by aggregating allocations into
larger blocks and freeing allocations all at once. Protocol messages are
allocated on an arena by using Arena::Create
<T
>(Arena*), below, and are
automatically freed when the arena is destroyed.
This is a thread-safe implementation: multiple threads may allocate from the
arena concurrently. Destruction is not thread-safe and the destructing
thread must synchronize with users of the arena first.
Public Members
static const size_t kBlockOverhead
Public Methods
void Arena ()
Default constructor with sensible default options, tuned for average
use-cases.
Defined at line 173 of file ../../third_party/protobuf/src/google/protobuf/arena.h
void Arena (char * initial_block, size_t initial_block_size)
Construct an arena with default options, except for the supplied
initial block. It is more efficient to use this constructor
instead of passing ArenaOptions if the only configuration needed
by the caller is supplying an initial block.
Defined at line 179 of file ../../third_party/protobuf/src/google/protobuf/arena.h
void Arena (const ArenaOptions & options)
Arena constructor taking custom options. See ArenaOptions above for
descriptions of the options available.
Defined at line 184 of file ../../third_party/protobuf/src/google/protobuf/arena.h
void ~Arena ()
Defined at line 198 of file ../../third_party/protobuf/src/google/protobuf/arena.h
template <typename T, typename... Args>
T * CreateMessage (Arena * arena, Args &&... args)
Deprecated. Use Create
<T
> instead.
Defined at line 203 of file ../../third_party/protobuf/src/google/protobuf/arena.h
template <typename T, typename... Args>
T * Create (Arena * arena, Args &&... args)
Allocates an object type T if the arena passed in is not nullptr;
otherwise, returns a heap-allocated object.
Defined at line 216 of file ../../third_party/protobuf/src/google/protobuf/arena.h
template <typename T>
void Destroy (T * obj)
API to delete any objects not on an arena. This can be used to safely
clean up messages or repeated fields without knowing whether or not they're
owned by an arena. The pointer passed to this function should not be used
again.
Defined at line 259 of file ../../third_party/protobuf/src/google/protobuf/arena.h
void * AllocateAligned (size_t size, size_t align)
Allocates memory with the specific size and alignment.
Defined at line 264 of file ../../third_party/protobuf/src/google/protobuf/arena.h
template <typename T>
T * CreateArray (Arena * arena, size_t num_elements)
Create an array of object type T on the arena *without* invoking the
constructor of T. If `arena` is null, then the return value should be freed
with `delete[] x;` (or `::operator delete[](x);`).
To ensure safe uses, this function checks at compile time
(when compiled as C++11) that T is trivially default-constructible and
trivially destructible.
Defined at line 285 of file ../../third_party/protobuf/src/google/protobuf/arena.h
uint64_t SpaceAllocated ()
The following routines are for monitoring. They will approximate the total
sum allocated and used memory, but the exact value is an implementation
deal. For instance allocated space depends on growth policies. Do not use
these in unit tests. Returns the total space allocated by the arena, which
is the sum of the sizes of the underlying blocks.
Defined at line 308 of file ../../third_party/protobuf/src/google/protobuf/arena.h
uint64_t SpaceUsed ()
Returns the total space used by the arena. Similar to SpaceAllocated but
does not include free space and block overhead. This is a best-effort
estimate and may inaccurately calculate space used by other threads
executing concurrently with the call to this method. These inaccuracies
are due to race conditions, and are bounded but unpredictable. Stale data
can lead to underestimates of the space used, and race conditions can lead
to overestimates (up to the current block size).
Defined at line 316 of file ../../third_party/protobuf/src/google/protobuf/arena.h
uint64_t Reset ()
Frees all storage allocated by this arena after calling destructors
registered with OwnDestructor() and freeing objects registered with Own().
Any objects allocated on this arena are unusable after this call. It also
returns the total space used by the arena which is the sums of the sizes
of the allocated blocks. This method is not thread-safe.
Defined at line 323 of file ../../third_party/protobuf/src/google/protobuf/arena.h
template <typename T>
void Own (T * object)
Adds |object| to a list of heap-allocated objects to be freed with |delete|
when the arena is destroyed or reset.
Defined at line 328 of file ../../third_party/protobuf/src/google/protobuf/arena.h
template <typename T>
void OwnDestructor (T * object)
Adds |object| to a list of objects whose destructors will be manually
called when the arena is destroyed or reset. This differs from Own() in
that it does not free the underlying memory with |delete|; hence, it is
normally only used for objects that are placement-newed into
arena-allocated memory.
Defined at line 346 of file ../../third_party/protobuf/src/google/protobuf/arena.h
void OwnCustomDestructor (void * object, void (*)(void *) destruct)
Adds a custom member function on an object to the list of destructors that
will be manually called when the arena is destroyed or reset. This differs
from OwnDestructor() in that any member function may be specified, not only
the class destructor.
Defined at line 356 of file ../../third_party/protobuf/src/google/protobuf/arena.h
template <typename T>
Arena * GetArena (T * value)
Retrieves the arena associated with |value| if |value| is an arena-capable
message, or nullptr otherwise. If possible, the call resolves at compile
time. Note that we can often devirtualize calls to `value->GetArena()` so
usually calling this method is unnecessary.
TODO: remove this function.
Defined at line 367 of file ../../third_party/protobuf/src/google/protobuf/arena.h
template <typename T>
Arena * InternalGetArena (T * p)
Provides access to protected GetArena to generated messages.
For internal use only.
Defined at line 472 of file ../../third_party/protobuf/src/google/protobuf/arena.h
Records
Friends
class ArenaTestPeer
class ExtensionSet
class UntypedMapBase
class RepeatedPtrFieldBase
template <typename>
class RepeatedField
template <typename Key, typename T>
class Map
class MessageLite
class TcParser
class EpsCopyInputStream
class LazyField
class InternalMetadata
template <typename Type>
class GenericTypeHandler