class ThreadSafeArena

Defined at line 45 of file ../../third_party/protobuf/src/src/google/protobuf/thread_safe_arena.h

This class provides the core Arena memory allocation library. Different

implementations only need to implement the public interface below.

Arena is not a template type as that would only be useful if all protos

in turn would be templates, which will/cannot happen. However separating

the memory allocation part from the cruft of the API users expect we can

use #ifdef the select the best implementation based on hardware / OS.

Public Members

static const size_t kBlockHeaderSize
static const size_t kSerialArenaSize
static const size_t kAllocPolicySize
static const size_t kMaxCleanupNodeSize

Public Methods

template <AllocationClient alloc_client = AllocationClient::kDefault>
void * AllocateAligned (size_t n)

Defined at line 73 of file ../../third_party/protobuf/src/src/google/protobuf/thread_safe_arena.h

void ThreadSafeArena ()
void ThreadSafeArena (char * mem, size_t size)
void ThreadSafeArena (void * mem, size_t size, const AllocationPolicy & policy)
void * AllocateAlignedWithCleanup (size_t n, size_t align, void (*)(void *) destructor)
void AddCleanup (void * elem, void (*)(void *) cleanup)

Add object pointer and cleanup function pointer to the list.

void * AllocateFromStringBlock ()
void ThreadSafeArena (const ThreadSafeArena & )

All protos have pointers back to the arena hence Arena must have

pointer stability.

Defined at line 56 of file ../../third_party/protobuf/src/src/google/protobuf/thread_safe_arena.h

ThreadSafeArena & operator= (const ThreadSafeArena & )

Defined at line 57 of file ../../third_party/protobuf/src/src/google/protobuf/thread_safe_arena.h

void ThreadSafeArena (ThreadSafeArena && )

Defined at line 58 of file ../../third_party/protobuf/src/src/google/protobuf/thread_safe_arena.h

ThreadSafeArena & operator= (ThreadSafeArena && )

Defined at line 59 of file ../../third_party/protobuf/src/src/google/protobuf/thread_safe_arena.h

void ReturnArrayMemory (void * p, size_t size)

Defined at line 82 of file ../../third_party/protobuf/src/src/google/protobuf/thread_safe_arena.h

bool MaybeAllocateAligned (size_t n, void ** out)

This function allocates n bytes if the common happy case is true and

returns true. Otherwise does nothing and returns false. This strange

semantics is necessary to allow callers to program functions that only

have fallback function calls in tail position. This substantially improves

code for the happy path.

Defined at line 94 of file ../../third_party/protobuf/src/src/google/protobuf/thread_safe_arena.h

void ~ThreadSafeArena ()

Destructor deletes all owned heap allocated objects, and destructs objects

that have non-trivial destructors, except for proto2 message objects whose

destructors can be skipped. Also, frees all blocks except the initial block

if it was passed in.

uint64_t Reset ()
uint64_t SpaceAllocated ()
uint64_t SpaceUsed ()
std::vector<void *> PeekCleanupListForTesting ()

Friends

SerialArena * ThreadSafeArena (Arena * )
class ChunkList
class SerialArenaChunkHeader
class SerialArena
class TcParser
class ArenaBenchmark