LLVM 24.0.0git
llvm::parallel::PerThreadAllocator< AllocatorTy > Class Template Reference

PerThreadAllocator wraps a thread-unsafe allocator (e.g. More...

#include "llvm/Support/PerThreadBumpPtrAllocator.h"

Inheritance diagram for llvm::parallel::PerThreadAllocator< AllocatorTy >:
[legend]

Public Member Functions

 PerThreadAllocator ()
void * Allocate (size_t Size, size_t Alignment)
 Allocate Size bytes of Alignment aligned memory.
void Deallocate (const void *Ptr, size_t Size, size_t Alignment)
 Deallocate Ptr to Size bytes of memory allocated by this allocator.
AllocatorTy & getThreadLocalAllocator ()
 Return the calling thread's sub-allocator, creating it on first use.
size_t getNumberOfAllocators () const
 Return the number of sub-allocators, i.e. threads that have allocated.
void Reset ()
 Reset state of allocators.
size_t getTotalMemory () const
 Return total memory size used by all allocators.
void setRedZoneSize (size_t NewSize)
 Set red zone for all allocators.
void PrintStats () const
 Print statistic for each allocator.
Public Member Functions inherited from llvm::AllocatorBase< PerThreadAllocator< AllocatorTy > >
void * Allocate (size_t Size, size_t Alignment)
 Allocate Size bytes of Alignment aligned memory.
void Deallocate (const void *Ptr, size_t Size, size_t Alignment)
 Deallocate Ptr to Size bytes of memory allocated by this allocator.

Protected Attributes

std::unique_ptr< State > S
unsigned Id

Detailed Description

template<typename AllocatorTy>
class llvm::parallel::PerThreadAllocator< AllocatorTy >

PerThreadAllocator wraps a thread-unsafe allocator (e.g.

BumpPtrAllocator) for lock-free concurrent allocation: each thread receives its own sub-allocator on first allocation, and the PerThreadAllocator owns all sub-allocators. Recommended to used with the thread pool in Parallel.h even if there is no dependency on it.

Definition at line 34 of file PerThreadBumpPtrAllocator.h.

Constructor & Destructor Documentation

◆ PerThreadAllocator()

template<typename AllocatorTy>
llvm::parallel::PerThreadAllocator< AllocatorTy >::PerThreadAllocator ( )
inline

Definition at line 43 of file PerThreadBumpPtrAllocator.h.

Member Data Documentation

◆ Id

template<typename AllocatorTy>
unsigned llvm::parallel::PerThreadAllocator< AllocatorTy >::Id
protected

Definition at line 133 of file PerThreadBumpPtrAllocator.h.

◆ S

template<typename AllocatorTy>
std::unique_ptr<State> llvm::parallel::PerThreadAllocator< AllocatorTy >::S
protected

Definition at line 132 of file PerThreadBumpPtrAllocator.h.


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