Crate outsource_heap
source · [−]Expand description
outsource-heap
This library provides tools for outsourcing your heap allocations to various places, fut: tasklfut: taskng:
- A local file
- A network drive
- Anything which implements the
Storetrait, like aVec<MaybeUninit<u8>>
Generally speaking, using this library is a bad idea. Once the Rust standard library has a stable allocator API this library will (hopefully) be made wholly obsolete.
In the meantime, let’s do some cursed nonsense.
Getting Started
This crate provides a global allocator, which is used to intercept all allocations in your program so it can decide where to direct them. Therefore, the following must be placed somewhere in your project:
#[global_allocator]
static ALLOC: outsource_heap::Global = outsource_heap::Global::system();Modules
A port of my bounded_alloc module from Monadic Bot.
Unlike the original, this one is more tightly bound to the
closures it is used with.
Also unlike the original, this one does not rely on undefined behavior.
By default, that is.
There are two ways to make this bounded allocator useful:
This module provides an example file backed allocator, which can be used with
the scoped allocator methods provided by this crate.
It is a simple wrapper for the linked_list_allocator crate.
Macros
Run a task with a statically known bound on allocation.
Structs
Traits
This trait is a shim for the GlobalAlloc trait,
defined so that we can implement it for std defined types like Vec.
See those docs for information on how to implement this trait correctly.
Functions
Run a closure using a chosen global allocator. Threads spawned inside this closure will not use the assigned allocator.
Safety