pub unsafe trait Backend {
    type Mutex: Mutex;

    // Required methods
    fn mreserve(ptr: *mut u8, size: usize) -> *mut u8;
    unsafe fn mcommit(ptr: *mut u8, size: usize) -> bool;
    unsafe fn mdecommit(ptr: *mut u8, size: usize);
    unsafe fn munreserve(ptr: *mut u8, size: usize);
    fn pagesize() -> usize;
    unsafe fn tls_attach(callback: *const TlsCallback);
}
Expand description

This trait contains external functions that are provided by the user in order for the library to perform system actions such as page allocation.

Safety

The implementation must make sure the functions in the trait behave properly.

Required Associated Types§

Required Methods§

source

fn mreserve(ptr: *mut u8, size: usize) -> *mut u8

Reserve the block of memory starting at ptr if ptr is not null and with size.

If ptr is null, the block of memory can start at an offset determined by the system.

If the function fails null is returned.

source

unsafe fn mcommit(ptr: *mut u8, size: usize) -> bool

Commit memory starting at ptr with size size.

If the function fails null is returned.

Safety

The memory must be reserved.

source

unsafe fn mdecommit(ptr: *mut u8, size: usize)

Decommit memory starting at ptr with size size.

Safety

The memory must be commited.

source

unsafe fn munreserve(ptr: *mut u8, size: usize)

Unreserve memory starting at ptr with size size.

Safety

The memory must be reserved.

The size must be equals to the same size used for reserving.

source

fn pagesize() -> usize

Returns the page size.

It is a good idea to cache before returning.

source

unsafe fn tls_attach(callback: *const TlsCallback)

Attach the given callback to this thread, running it when the thread is destroyed.

Safety

The callback must be #[thread_local].

Implementors§