rune::core::gc::context

Struct Context

Source
pub(crate) struct Context<'rt> {
    pub(crate) block: Block<false>,
    root_set: &'rt RootSet,
    next_limit: usize,
}
Expand description

Owns all allocations and creates objects. All objects have a lifetime tied to the borrow of their Context. When the Context goes out of scope, no objects should be accessible.

Fields§

§block: Block<false>§root_set: &'rt RootSet§next_limit: usize

Implementations§

Source§

impl<'ob, 'rt> Context<'rt>

Source

const MIN_GC_BYTES: usize = 2_000usize

Source

const GC_GROWTH_FACTOR: usize = 12usize

Source

pub(crate) fn new(roots: &'rt RootSet) -> Self

Source

pub(crate) fn from_block(block: Block<false>, roots: &'rt RootSet) -> Self

Source

pub(crate) fn bind<T>(&'ob self, obj: T) -> <T as WithLifetime<'ob>>::Out
where T: WithLifetime<'ob>,

Source

pub(crate) fn get_root_set(&'ob self) -> &'rt RootSet

Source

pub(crate) fn garbage_collect(&mut self, force: bool)

Methods from Deref<Target = Block<false>>§

Source

pub(crate) fn add<'ob, T, Tx>(&'ob self, obj: T) -> Gc<ObjectType<'ob>>
where T: IntoObject<Out<'ob> = Tx>, Gc<Tx>: Into<Gc<ObjectType<'ob>>>,

Source

pub(crate) fn add_as<'ob, T, Tx, V>(&'ob self, obj: T) -> Gc<V>
where T: IntoObject<Out<'ob> = Tx>, Gc<Tx>: Into<Gc<V>>,

Source

pub(crate) fn string_with_capacity(&self, cap: usize) -> String<'_>

Create a new String whose backing storage is already part of the GC heap. Does not require dropping when moved during garbage collection (unlike std::string).

Source

pub(crate) fn vec_new(&self) -> GcVec<'_, Gc<ObjectType<'_>>>

Create a new Vec whose backing storage is already part of the GC heap. Does not require dropping when moved during garbage collection (unlike std::vec).

Source

pub(crate) fn vec_with_capacity( &self, cap: usize, ) -> GcVec<'_, Gc<ObjectType<'_>>>

Trait Implementations§

Source§

impl AsRef<Block<false>> for Context<'_>

Source§

fn as_ref(&self) -> &Block<false>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl Drop for Context<'_>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl Deref for Context<'_>

Source§

type Target = Block<false>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<'rt> !Freeze for Context<'rt>

§

impl<'rt> !RefUnwindSafe for Context<'rt>

§

impl<'rt> !Send for Context<'rt>

§

impl<'rt> !Sync for Context<'rt>

§

impl<'rt> Unpin for Context<'rt>

§

impl<'rt> !UnwindSafe for Context<'rt>

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, 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.