Struct rarena_allocator::sync::Arena
source · pub struct Arena { /* private fields */ }Expand description
Arena should be lock-free
Trait Implementations§
source§impl Allocator for Arena
impl Allocator for Arena
source§type Path = Arc<PathBuf>
type Path = Arc<PathBuf>
Available on crate feature
memmap and non-target_family="wasm" only.The path type of the allocator.
source§fn reserved_bytes(&self) -> usize
fn reserved_bytes(&self) -> usize
Returns the number of bytes that are reserved by the allocator.
source§fn reserved_slice(&self) -> &[u8] ⓘ
fn reserved_slice(&self) -> &[u8] ⓘ
Returns the reserved bytes of the allocator specified in the
Options::with_reserved.source§unsafe fn reserved_slice_mut(&self) -> &mut [u8] ⓘ
unsafe fn reserved_slice_mut(&self) -> &mut [u8] ⓘ
Returns the mutable reserved bytes of the allocator specified in the
Options::with_reserved. Read moresource§unsafe fn alloc<T>(&self) -> Result<RefMut<'_, T, Self>, Error>
unsafe fn alloc<T>(&self) -> Result<RefMut<'_, T, Self>, Error>
Allocates a
T in the allocator. Read moresource§fn alloc_aligned_bytes<T>(
&self,
size: u32,
) -> Result<BytesRefMut<'_, Self>, Error>
fn alloc_aligned_bytes<T>( &self, size: u32, ) -> Result<BytesRefMut<'_, Self>, Error>
source§fn alloc_aligned_bytes_within_page<T>(
&self,
size: u32,
) -> Result<BytesRefMut<'_, Self>, Error>
fn alloc_aligned_bytes_within_page<T>( &self, size: u32, ) -> Result<BytesRefMut<'_, Self>, Error>
Available on crate feature
memmap and non-target_family="wasm" only.source§fn alloc_bytes(&self, size: u32) -> Result<BytesRefMut<'_, Self>, Error>
fn alloc_bytes(&self, size: u32) -> Result<BytesRefMut<'_, Self>, Error>
Allocates a slice of memory in the allocator. Read more
source§fn alloc_bytes_within_page(
&self,
size: u32,
) -> Result<BytesRefMut<'_, Self>, Error>
fn alloc_bytes_within_page( &self, size: u32, ) -> Result<BytesRefMut<'_, Self>, Error>
Available on crate feature
memmap and non-target_family="wasm" only.Allocates a slice of memory in the allocator in the same page. Read more
source§unsafe fn alloc_within_page<T>(&self) -> Result<RefMut<'_, T, Self>, Error>
unsafe fn alloc_within_page<T>(&self) -> Result<RefMut<'_, T, Self>, Error>
Available on crate feature
memmap and non-target_family="wasm" only.Allocates a
T in the allocator in the same page. Read moresource§fn allocated(&self) -> usize
fn allocated(&self) -> usize
Returns the number of bytes allocated by the allocator. Read more
source§fn raw_mut_ptr(&self) -> *mut u8
fn raw_mut_ptr(&self) -> *mut u8
Returns the start pointer of the main memory of the allocator.
source§fn data_offset(&self) -> usize
fn data_offset(&self) -> usize
Returns the data offset of the allocator. The offset is the end of the reserved bytes of the allocator. Read more
source§unsafe fn dealloc(&self, offset: u32, size: u32) -> bool
unsafe fn dealloc(&self, offset: u32, size: u32) -> bool
Deallocates the memory at the given offset and size, the
offset..offset + size will be made to a segment,
returns true if the deallocation is successful. Read moresource§fn discard_freelist(&self) -> Result<u32, Error>
fn discard_freelist(&self) -> Result<u32, Error>
Discards all freelist nodes in the allocator. Read more
source§fn flush(&self) -> Result<()>
fn flush(&self) -> Result<()>
Available on crate feature
memmap and non-target_family="wasm" only.Flushes the memory-mapped file to disk. Read more
source§fn flush_async(&self) -> Result<()>
fn flush_async(&self) -> Result<()>
Available on crate feature
memmap and non-target_family="wasm" only.Flushes the memory-mapped file to disk asynchronously. Read more
source§fn flush_range(&self, offset: usize, len: usize) -> Result<()>
fn flush_range(&self, offset: usize, len: usize) -> Result<()>
Available on crate feature
memmap and non-target_family="wasm" only.Flushes outstanding memory map modifications in the range to disk. Read more
source§fn flush_async_range(&self, offset: usize, len: usize) -> Result<()>
fn flush_async_range(&self, offset: usize, len: usize) -> Result<()>
Available on crate feature
memmap and non-target_family="wasm" only.Asynchronously flushes outstanding memory map modifications in the range to disk. Read more
source§fn increase_discarded(&self, size: u32)
fn increase_discarded(&self, size: u32)
Forcelly increases the discarded bytes. Read more
source§fn is_mmap(&self) -> bool
fn is_mmap(&self) -> bool
Available on crate feature
memmap and non-target_family="wasm" only.Returns
true if the allocator is created through memory map. Read moresource§fn is_ondisk_and_mmap(&self) -> bool
fn is_ondisk_and_mmap(&self) -> bool
Available on crate feature
memmap and non-target_family="wasm" only.Returns
true if the allocator is on-disk and created through memory map. Read moresource§fn lock_exclusive(&self) -> Result<()>
fn lock_exclusive(&self) -> Result<()>
Available on crate feature
memmap and non-target_family="wasm" only.Locks the underlying file for exclusive access, only works on mmap with a file backend. Read more
Available on crate feature
memmap and non-target_family="wasm" only.Locks the underlying file for shared access, only works on mmap with a file backend. Read more
source§fn magic_version(&self) -> u16
fn magic_version(&self) -> u16
source§fn minimum_segment_size(&self) -> u32
fn minimum_segment_size(&self) -> u32
Returns the minimum segment size of the allocator. Read more
source§fn set_minimum_segment_size(&self, size: u32)
fn set_minimum_segment_size(&self, size: u32)
Sets the minimum segment size of the allocator. Read more
source§fn path(&self) -> Option<&Self::PathRefCounter>
fn path(&self) -> Option<&Self::PathRefCounter>
Available on crate feature
memmap and non-target_family="wasm" only.Returns the path of the mmap file, only returns
Some when the ARENA is backed by a mmap file. Read moresource§unsafe fn mlock(&self, offset: usize, len: usize) -> Result<()>
unsafe fn mlock(&self, offset: usize, len: usize) -> Result<()>
Available on crate feature
memmap and non-target_family="wasm" and non-Windows only.mlock(ptr, len)—Lock memory into RAM. Read moresource§unsafe fn munlock(&self, offset: usize, len: usize) -> Result<()>
unsafe fn munlock(&self, offset: usize, len: usize) -> Result<()>
Available on crate feature
memmap and non-target_family="wasm" and non-Windows only.munlock(ptr, len)—Unlock memory. Read moresource§unsafe fn offset(&self, ptr: *const u8) -> usize
unsafe fn offset(&self, ptr: *const u8) -> usize
Returns the offset to the start of the allocator. Read more
source§fn remaining(&self) -> usize
fn remaining(&self) -> usize
Returns the number of bytes remaining bytes can be allocated by the allocator. Read more
source§fn remove_on_drop(&self, remove_on_drop: bool)
fn remove_on_drop(&self, remove_on_drop: bool)
Available on crate feature
memmap and non-target_family="wasm" only.Sets remove on drop, only works on mmap with a file backend. Read more
source§unsafe fn rewind(&self, pos: ArenaPosition)
unsafe fn rewind(&self, pos: ArenaPosition)
Set back the allocator’s main memory cursor to the given position. Read more
source§fn try_lock_exclusive(&self) -> Result<()>
fn try_lock_exclusive(&self) -> Result<()>
Available on crate feature
memmap and non-target_family="wasm" only.Try to lock the underlying file for exclusive access, only works on mmap with a file backend. Read more
Available on crate feature
memmap and non-target_family="wasm" only.Try to lock the underlying file for shared access, only works on mmap with a file backend. Read more
source§fn unlock(&self) -> Result<()>
fn unlock(&self) -> Result<()>
Available on crate feature
memmap and non-target_family="wasm" only.Unlocks the underlying file, only works on mmap with a file backend. Read more
source§fn alloc_aligned_bytes_owned_within_page<T>(
&self,
size: u32,
) -> Result<BytesMut<Self>, Error>
fn alloc_aligned_bytes_owned_within_page<T>( &self, size: u32, ) -> Result<BytesMut<Self>, Error>
Available on crate feature
memmap and non-target_family="wasm" only.source§fn alloc_bytes_owned(&self, size: u32) -> Result<BytesMut<Self>, Error>
fn alloc_bytes_owned(&self, size: u32) -> Result<BytesMut<Self>, Error>
Allocates an owned slice of memory in the allocator. Read more
source§fn alloc_bytes_owned_within_page(
&self,
size: u32,
) -> Result<BytesMut<Self>, Error>
fn alloc_bytes_owned_within_page( &self, size: u32, ) -> Result<BytesMut<Self>, Error>
Available on crate feature
memmap and non-target_family="wasm" only.Allocates an owned slice of memory in the allocator in the same page. Read more
source§unsafe fn alloc_owned_within_page<T>(&self) -> Result<Owned<T, Self>, Error>
unsafe fn alloc_owned_within_page<T>(&self) -> Result<Owned<T, Self>, Error>
Available on crate feature
memmap and non-target_family="wasm" only.Allocates a
T in the allocator in the same page. Like alloc_within_page, but returns an Owned. Read moresource§fn allocated_memory(&self) -> &[u8] ⓘ
fn allocated_memory(&self) -> &[u8] ⓘ
Returns the whole main memory of the allocator as a byte slice. Read more
source§fn data(&self) -> &[u8] ⓘ
fn data(&self) -> &[u8] ⓘ
Returns the data section of the allocator as a byte slice, header is not included. Read more
source§unsafe fn get_pointer(&self, offset: usize) -> *const u8
unsafe fn get_pointer(&self, offset: usize) -> *const u8
Returns a pointer to the memory at the given offset. Read more
source§unsafe fn get_pointer_mut(&self, offset: usize) -> *mut u8
unsafe fn get_pointer_mut(&self, offset: usize) -> *mut u8
Returns a pointer to the memory at the given offset.
If the allocator is read-only, then this method will return a null pointer. Read more
source§unsafe fn get_aligned_pointer<T>(&self, offset: usize) -> *const T
unsafe fn get_aligned_pointer<T>(&self, offset: usize) -> *const T
Returns an aligned pointer to the memory at the given offset. Read more
source§unsafe fn get_aligned_pointer_mut<T>(&self, offset: usize) -> NonNull<T>
unsafe fn get_aligned_pointer_mut<T>(&self, offset: usize) -> NonNull<T>
Returns an aligned pointer to the memory at the given offset.
If the allocator is read-only, then this method will return a null pointer. Read more
source§unsafe fn get_bytes(&self, offset: usize, size: usize) -> &[u8] ⓘ
unsafe fn get_bytes(&self, offset: usize, size: usize) -> &[u8] ⓘ
Returns a bytes slice from the allocator. Read more
source§unsafe fn get_u8_unchecked(&self, offset: usize) -> u8
unsafe fn get_u8_unchecked(&self, offset: usize) -> u8
Returns a
u8 from the allocator without bounds checking. Read moresource§unsafe fn get_i8_unchecked(&self, offset: usize) -> i8
unsafe fn get_i8_unchecked(&self, offset: usize) -> i8
Returns a
i8 from the allocator without bounds checking. Read moresource§unsafe fn get_u16_be_unchecked(&self, offset: usize) -> u16
unsafe fn get_u16_be_unchecked(&self, offset: usize) -> u16
Returns a
u16 from the allocator without bounds checking. Read moresource§unsafe fn get_u16_le_unchecked(&self, offset: usize) -> u16
unsafe fn get_u16_le_unchecked(&self, offset: usize) -> u16
Returns a
u16 from the allocator without bounds checking. Read moresource§unsafe fn get_u32_be_unchecked(&self, offset: usize) -> u32
unsafe fn get_u32_be_unchecked(&self, offset: usize) -> u32
Returns a
u32 from the allocator without bounds checking. Read moresource§unsafe fn get_u32_le_unchecked(&self, offset: usize) -> u32
unsafe fn get_u32_le_unchecked(&self, offset: usize) -> u32
Returns a
u32 from the allocator without bounds checking. Read moresource§unsafe fn get_u64_be_unchecked(&self, offset: usize) -> u64
unsafe fn get_u64_be_unchecked(&self, offset: usize) -> u64
Returns a
u64 from the allocator without bounds checking. Read moresource§unsafe fn get_u64_le_unchecked(&self, offset: usize) -> u64
unsafe fn get_u64_le_unchecked(&self, offset: usize) -> u64
Returns a
u64 from the allocator without bounds checking. Read moresource§fn get_u128_be(&self, offset: usize) -> Result<u128, Error>
fn get_u128_be(&self, offset: usize) -> Result<u128, Error>
Returns a
u128 from the allocator.source§unsafe fn get_u128_be_unchecked(&self, offset: usize) -> u128
unsafe fn get_u128_be_unchecked(&self, offset: usize) -> u128
Returns a
u128 from the allocator without bounds checking. Read moresource§fn get_u128_le(&self, offset: usize) -> Result<u128, Error>
fn get_u128_le(&self, offset: usize) -> Result<u128, Error>
Returns a
u128 from the allocator.source§unsafe fn get_u128_le_unchecked(&self, offset: usize) -> u128
unsafe fn get_u128_le_unchecked(&self, offset: usize) -> u128
Returns a
u128 from the allocator without bounds checking. Read moresource§unsafe fn get_i16_be_unchecked(&self, offset: usize) -> i16
unsafe fn get_i16_be_unchecked(&self, offset: usize) -> i16
Returns a
i16 from the allocator without bounds checking. Read moresource§unsafe fn get_i16_le_unchecked(&self, offset: usize) -> i16
unsafe fn get_i16_le_unchecked(&self, offset: usize) -> i16
Returns a
i16 from the allocator without bounds checking. Read moresource§unsafe fn get_i32_be_unchecked(&self, offset: usize) -> i32
unsafe fn get_i32_be_unchecked(&self, offset: usize) -> i32
Returns a
i32 from the allocator without bounds checking. Read moresource§unsafe fn get_i32_le_unchecked(&self, offset: usize) -> i32
unsafe fn get_i32_le_unchecked(&self, offset: usize) -> i32
Returns a
i32 from the allocator without bounds checking. Read moresource§unsafe fn get_i64_be_unchecked(&self, offset: usize) -> i64
unsafe fn get_i64_be_unchecked(&self, offset: usize) -> i64
Returns a
i64 from the allocator without bounds checking. Read moresource§unsafe fn get_i64_le_unchecked(&self, offset: usize) -> i64
unsafe fn get_i64_le_unchecked(&self, offset: usize) -> i64
Returns a
i64 from the allocator without bounds checking. Read moresource§fn get_i128_be(&self, offset: usize) -> Result<i128, Error>
fn get_i128_be(&self, offset: usize) -> Result<i128, Error>
Returns a
i128 from the allocator.source§unsafe fn get_i128_be_unchecked(&self, offset: usize) -> i128
unsafe fn get_i128_be_unchecked(&self, offset: usize) -> i128
Returns a
i128 from the allocator without bounds checking. Read moresource§fn get_i128_le(&self, offset: usize) -> Result<i128, Error>
fn get_i128_le(&self, offset: usize) -> Result<i128, Error>
Returns a
i128 from the allocator.source§unsafe fn get_i128_le_unchecked(&self, offset: usize) -> i128
unsafe fn get_i128_le_unchecked(&self, offset: usize) -> i128
Returns a
i128 from the allocator without bounds checking. Read moresource§fn get_i16_varint(&self, offset: usize) -> Result<(usize, i16), Error>
fn get_i16_varint(&self, offset: usize) -> Result<(usize, i16), Error>
Returns a
i16 in LEB128 format from the allocator at the given offset. Read moresource§fn get_i32_varint(&self, offset: usize) -> Result<(usize, i32), Error>
fn get_i32_varint(&self, offset: usize) -> Result<(usize, i32), Error>
Returns a
i32 in LEB128 format from the allocator at the given offset. Read moresource§fn get_i64_varint(&self, offset: usize) -> Result<(usize, i64), Error>
fn get_i64_varint(&self, offset: usize) -> Result<(usize, i64), Error>
Returns a
i64 in LEB128 format from the allocator at the given offset. Read moresource§fn get_i128_varint(&self, offset: usize) -> Result<(usize, i128), Error>
fn get_i128_varint(&self, offset: usize) -> Result<(usize, i128), Error>
Returns a
i128 in LEB128 format from the allocator at the given offset. Read moresource§fn get_u16_varint(&self, offset: usize) -> Result<(usize, u16), Error>
fn get_u16_varint(&self, offset: usize) -> Result<(usize, u16), Error>
Returns a
u16 in LEB128 format from the allocator at the given offset. Read moresource§fn get_u32_varint(&self, offset: usize) -> Result<(usize, u32), Error>
fn get_u32_varint(&self, offset: usize) -> Result<(usize, u32), Error>
Returns a
u32 in LEB128 format from the allocator at the given offset. Read moresource§fn get_u64_varint(&self, offset: usize) -> Result<(usize, u64), Error>
fn get_u64_varint(&self, offset: usize) -> Result<(usize, u64), Error>
Returns a
u64 in LEB128 format from the allocator at the given offset. Read moresource§fn get_u128_varint(&self, offset: usize) -> Result<(usize, u128), Error>
fn get_u128_varint(&self, offset: usize) -> Result<(usize, u128), Error>
Returns a
u128 in LEB128 format from the allocator at the given offset. Read moresource§unsafe fn get_bytes_mut(&self, offset: usize, size: usize) -> &mut [u8] ⓘ
unsafe fn get_bytes_mut(&self, offset: usize, size: usize) -> &mut [u8] ⓘ
Returns a mutable bytes slice from the allocator.
If the allocator is read-only, then this method will return an empty slice. Read more
source§fn memory(&self) -> &[u8] ⓘ
fn memory(&self) -> &[u8] ⓘ
Returns the whole main memory of the allocator as a byte slice. Read more
source§fn checksum<S: BuildChecksumer>(&self, cks: &S) -> u64
fn checksum<S: BuildChecksumer>(&self, cks: &S) -> u64
Calculates the checksum of the allocated memory (excluding the reserved memory specified by users through
Options::with_reserved) of the allocator.impl Send for Arena
impl Sync for Arena
Auto Trait Implementations§
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more