Skip to main content

SlabRemote

Struct SlabRemote 

Source
pub struct SlabRemote<T, B: Allocator + FixedRange> { /* private fields */ }
Expand description

Remote deallocation handle. Send + Sync — freely cloneable across threads. Implements Deallocator only; cannot allocate.

§API-misuse compile-failures (pinned)

SlabRemote<T, B> is Send + Sync only when T: Send (and B: Send). Instantiating with a non-Send T (e.g. Rc<u64>) and then trying to ship the remote across threads is rejected at compile time:

// FAILS TO COMPILE: SlabRemote's `Send` bound requires `T: Send`,
// so `SlabRemote<Rc<u64>, _>` is not `Send` and cannot satisfy
// `assert_send`.
use std::rc::Rc;
use forge_alloc::InlineBacked;
use forge_alloc::SlabRemote;
fn assert_send<T: Send>() {}
assert_send::<SlabRemote<Rc<u64>, InlineBacked<512>>>();

Implementations§

Source§

impl<T, B: Allocator + FixedRange> SlabRemote<T, B>

Source

pub unsafe fn try_deallocate( &self, ptr: NonNull<u8>, layout: NonZeroLayout, ) -> Result<(), NonNull<u8>>

Non-spinning remote deallocate. Returns Err(ptr) if the queue is full or the owner has been dropped (queue is closed); caller retains ownership and must handle the pointer (typically by dropping it once the whole slab tears down).

§Safety

ptr must have been allocated from the corresponding SlabOwner. On Err, the pointer is still owned by the caller.

Trait Implementations§

Source§

impl<T: Clone, B: Clone + Allocator + FixedRange> Clone for SlabRemote<T, B>

Source§

fn clone(&self) -> SlabRemote<T, B>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T, B: Allocator + FixedRange> Deallocator for SlabRemote<T, B>

Source§

unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: NonZeroLayout)

Spins until the queue accepts the deallocation, except when the owner has been dropped — in that case the queue will never drain again, so we return immediately. The slot remains marked-live in the slab until the last SlabRemote clone releases the shared Arc<SlabInner> (at which point the slab itself drops and the backing region is fully reclaimed). Any T: Drop whose destructor was already run by the caller before deallocate is not affected — the destructor ran on schedule; only the freelist entry for the slot is forfeited.

Latency-sensitive callers should use try_deallocate and handle the Err(ptr) overflow / closed-queue explicitly.

Source§

impl<T: Send, B: Allocator + FixedRange + Send> Send for SlabRemote<T, B>

Source§

impl<T: Send, B: Allocator + FixedRange + Send> Sync for SlabRemote<T, B>

Auto Trait Implementations§

§

impl<T, B> !RefUnwindSafe for SlabRemote<T, B>

§

impl<T, B> !UnwindSafe for SlabRemote<T, B>

§

impl<T, B> Freeze for SlabRemote<T, B>

§

impl<T, B> Unpin for SlabRemote<T, B>

§

impl<T, B> UnsafeUnpin for SlabRemote<T, B>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.