webrender::frame_allocator

Struct FrameMemory

Source
pub struct FrameMemory {
    allocator: Option<NonNull<FrameInnerAllocator>>,
    references_created: UnsafeCell<i32>,
}
Expand description

The backing storage for FrameAllocator

This object is meant to be stored in the built frame and must not be dropped or recycled before all allocations have been deallocated and all FrameAllocators have been dropped. In other words, drop or recycle this after dropping the rest of the built frame.

Fields§

§allocator: Option<NonNull<FrameInnerAllocator>>

Safety: The pointed FrameInnerAllocator must not move or be deallocated while there are live FrameAllocators pointing to it. This is ensured by respecting that the FrameMemory is dropped last and by the FrameInnerAllocator not being exposed to the outside world. It is also checked at runtime via the reference count.

§references_created: UnsafeCell<i32>

The number of FrameAllocators created during the current frame. This is used to compare aganst the inner allocator’s dropped references counter to check that references have all been dropped before freeing or recycling the memory.

Implementations§

Source§

impl FrameMemory

Source

pub fn fallback() -> Self

Creates a fallback FrameMemory that uses the global allocator.

This should only be used for testing purposes and to handle the deserialization of webrender recordings.

Source

pub fn new(pool: Arc<ChunkPool>) -> Self

§Panics

A FrameMemory must not be dropped until all of the associated FrameAllocators as well as their allocations have been dropped, otherwise the FrameMemory::drop will panic.

Source

pub fn allocator(&self) -> FrameAllocator

Create a FrameAllocator for the current frame.

Source

pub fn new_vec<T>(&self) -> Vec<T, FrameAllocator>

Shorthand for creating a FrameVec.

Source

pub fn new_vec_with_capacity<T>(&self, cap: usize) -> Vec<T, FrameAllocator>

Shorthand for creating a FrameVec.

Source

pub fn assert_memory_reusable(&self)

Panics if there are still live allocations or FrameAllocators.

Source

pub fn begin_frame(&mut self, id: FrameId)

Must be called at the beginning of each frame before creating any FrameAllocator.

Source

pub fn get_stats(&self) -> Stats

Trait Implementations§

Source§

impl Drop for FrameMemory

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Serialize for FrameMemory

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Send for FrameMemory

Auto Trait Implementations§

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> 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> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.