Struct slab_alloc::UntypedSlabAllocBuilder [] [src]

pub struct UntypedSlabAllocBuilder<I: InitSystem> { /* fields omitted */ }

A builder for UntypedSlabAllocs.

Methods

impl<I: InitSystem> UntypedSlabAllocBuilder<I>
[src]

[src]

Updates the alignment guaranteed by the allocator.

align must not be greater than the size of allocated objects, must not be greater than the system's page size, and must be a power of two. The size of allocated objects must be a multiple of align.

If align is called multiple times, then the largest specified alignment will be used. Since all alignments must be powers of two, allocations which satisfy the largest specified alignment will also satisfy all smaller alignments.

[src]

Builds an UntypedSlabAlloc whose memory is backed by the heap.

[src]

Builds an UntypedSlabAlloc whose memory is backed by mmap.

On Unix and Linux, mmap is used. On Windows, VirtualAlloc is used.

[src]

Builds a new UntypedSlabAlloc with a custom memory provider.

build_backing builds a new UntypedSlabAlloc from the configuration self. UntypedSlabAllocs get their memory from UntypedObjectAllocs which allocate the memory necessary to back a single slab. Under the hood, slab allocators use two types of slabs - "aligned" slabs and "large" slabs. Aligned slabs perform better, but are not always supported for all slab sizes. Large slabs do not perform as well, but are supported for all slab sizes. In particular, aligned slabs require that the memory used to back them is aligned to its own size (ie, a 16K slab has alignment 16K, etc), while large slabs only require page alignment regardless of the slab size. All slabs are always at least one page in size and are always page-aligned at a minimum.

Because support for a particular slab size may not be knowable until runtime (e.g., it may depend on the page size, which can vary by system), which slab type will be used cannot be known at compile time. Instead, build_backing computes the ideal aligned slab size, and calls get_aligned with a Layout describing that size. get_aligned returns an Option - None if the requested size is not supported, and Some if the size is supported. If the size is not supported, build_backing will fall back to using large slabs, and will call get_large to get an allocator. It will only call get_large with a Layout that is required to be supported (at least a page in size and page-aligned), so get_large returns an allocator directly rather than an Option.

impl<F: Fn(*mut u8)> UntypedSlabAllocBuilder<InitInitSystem<u8, UnsafeFnInitializer<u8, F>>>
[src]

[src]

impl UntypedSlabAllocBuilder<NopInitSystem>
[src]

[src]