LLVM 19.0.0git
Classes | Public Member Functions | List of all members
llvm::ThreadSafeAllocator< AllocatorType > Class Template Reference

Thread-safe allocator adaptor. More...

#include "llvm/Support/ThreadSafeAllocator.h"

Public Member Functions

auto Allocate (size_t N)
 
auto Allocate (size_t Size, size_t Align)
 
template<typename FnT , typename T = typename llvm::function_traits<FnT>::result_t>
T applyLocked (FnT Fn)
 

Detailed Description

template<class AllocatorType>
class llvm::ThreadSafeAllocator< AllocatorType >

Thread-safe allocator adaptor.

Uses a spin lock on the assumption that contention here is extremely rare.

TODO: Using a spin lock on every allocation can be quite expensive when contention is high. Since this is mainly used for BumpPtrAllocator and SpecificBumpPtrAllocator, it'd be better to have a specific thread-safe BumpPtrAllocator implementation that only use a fair lock when allocating a new slab but otherwise using atomic and be lock-free.

Definition at line 26 of file ThreadSafeAllocator.h.

Member Function Documentation

◆ Allocate() [1/2]

template<class AllocatorType >
auto llvm::ThreadSafeAllocator< AllocatorType >::Allocate ( size_t  N)
inline

◆ Allocate() [2/2]

template<class AllocatorType >
auto llvm::ThreadSafeAllocator< AllocatorType >::Allocate ( size_t  Size,
size_t  Align 
)
inline

◆ applyLocked()

template<class AllocatorType >
template<typename FnT , typename T = typename llvm::function_traits<FnT>::result_t>
T llvm::ThreadSafeAllocator< AllocatorType >::applyLocked ( FnT  Fn)
inline

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