LLVM 22.0.0git
|
Allocator for an owned mapped file region that supports thread-safe and process-safe bump pointer allocation. More...
#include "llvm/CAS/MappedFileRegionArena.h"
Classes | |
struct | Header |
Header for MappedFileRegionArena. More... |
Public Types | |
using | RegionT = sys::fs::mapped_file_region |
Public Member Functions | |
Expected< char * > | allocate (uint64_t AllocSize) |
Allocate at least AllocSize . Rounds up to getAlign(). | |
Expected< int64_t > | allocateOffset (uint64_t AllocSize) |
Allocate, returning the offset from data() instead of a pointer. | |
char * | data () const |
uint64_t | size () const |
uint64_t | capacity () const |
RegionT & | getRegion () |
~MappedFileRegionArena () | |
MappedFileRegionArena ()=default | |
MappedFileRegionArena (MappedFileRegionArena &&RHS) | |
MappedFileRegionArena & | operator= (MappedFileRegionArena &&RHS) |
MappedFileRegionArena (const MappedFileRegionArena &)=delete | |
MappedFileRegionArena & | operator= (const MappedFileRegionArena &)=delete |
Static Public Member Functions | |
static Expected< MappedFileRegionArena > | create (const Twine &Path, uint64_t Capacity, uint64_t HeaderOffset, function_ref< Error(MappedFileRegionArena &)> NewFileConstructor) |
Create a MappedFileRegionArena . | |
static constexpr Align | getAlign () |
Minimum alignment for allocations, currently hardcoded to 8B. |
Allocator for an owned mapped file region that supports thread-safe and process-safe bump pointer allocation.
This allocator is designed to create a sparse file when supported by the filesystem's ftruncate
so that it can be used with a large maximum size. It will also attempt to shrink the underlying file down to its current allocation size when the last concurrent mapping is closed.
Process-safe. Uses file locks when resizing the file during initialization and destruction.
Thread-safe. Requires OS support thread-safe file lock.
Provides 8-byte alignment for all allocations.
Definition at line 38 of file MappedFileRegionArena.h.
Definition at line 40 of file MappedFileRegionArena.h.
|
inline |
Definition at line 92 of file MappedFileRegionArena.h.
|
default |
Referenced by create(), MappedFileRegionArena(), MappedFileRegionArena(), operator=(), and operator=().
|
inline |
Definition at line 95 of file MappedFileRegionArena.h.
References MappedFileRegionArena(), and RHS.
|
delete |
References MappedFileRegionArena().
Allocate at least AllocSize
. Rounds up to getAlign().
Definition at line 77 of file MappedFileRegionArena.h.
References allocateOffset(), data(), LLVM_UNLIKELY, and llvm::Offset.
Allocate, returning the offset from data() instead of a pointer.
Definition at line 336 of file MappedFileRegionArena.cpp.
References llvm::alignTo(), assert(), capacity(), createAllocatorOutOfSpaceError(), getAlign(), LLVM_UNLIKELY, and llvm::cas::ondisk::preallocateFileTail().
Referenced by allocate().
|
inline |
Definition at line 88 of file MappedFileRegionArena.h.
Referenced by allocateOffset().
|
static |
Create a MappedFileRegionArena
.
Path | the path to open the mapped region. |
Capacity | the maximum size for the mapped file region. |
HeaderOffset | the offset at which to store the header. This is so that information can be stored before the header, like a file magic. |
NewFileConstructor | is for constructing new files. It has exclusive access to the file. Must call initializeBumpPtr . |
Definition at line 160 of file MappedFileRegionArena.cpp.
References llvm::SmallString< InternalLen >::append(), assert(), llvm::sys::fs::convertFDToNativeFile(), llvm::createFileError(), llvm::createStringError(), llvm::sys::fs::Exclusive, MappedFileRegionArena(), llvm::sys::fs::readNativeFileSlice(), llvm::sys::fs::mapped_file_region::readwrite, llvm::sys::fs::resize_file_sparse(), llvm::sys::fs::Shared, Size, and llvm::utostr().
|
inline |
Definition at line 86 of file MappedFileRegionArena.h.
Referenced by allocate().
|
inlinestaticconstexpr |
Minimum alignment for allocations, currently hardcoded to 8B.
Definition at line 69 of file MappedFileRegionArena.h.
References llvm::Align::Of(), and T.
Referenced by allocateOffset().
|
inline |
Definition at line 90 of file MappedFileRegionArena.h.
|
delete |
References MappedFileRegionArena(), and RHS.
|
inline |
Definition at line 96 of file MappedFileRegionArena.h.
References MappedFileRegionArena(), and RHS.
|
inline |
Definition at line 87 of file MappedFileRegionArena.h.