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>
impl<'ob, 'rt> Context<'rt>
const MIN_GC_BYTES: usize = 2_000usize
const GC_GROWTH_FACTOR: usize = 12usize
pub(crate) fn new(roots: &'rt RootSet) -> Self
pub(crate) fn from_block(block: Block<false>, roots: &'rt RootSet) -> Self
pub(crate) fn bind<T>(&'ob self, obj: T) -> <T as WithLifetime<'ob>>::Outwhere
T: WithLifetime<'ob>,
pub(crate) fn get_root_set(&'ob self) -> &'rt RootSet
pub(crate) fn garbage_collect(&mut self, force: bool)
Methods from Deref<Target = Block<false>>§
pub(crate) fn add<'ob, T, Tx>(&'ob self, obj: T) -> Gc<ObjectType<'ob>>
pub(crate) fn add_as<'ob, T, Tx, V>(&'ob self, obj: T) -> Gc<V>
Sourcepub(crate) fn string_with_capacity(&self, cap: usize) -> String<'_>
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).
Sourcepub(crate) fn vec_new(&self) -> GcVec<'_, Gc<ObjectType<'_>>>
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).
pub(crate) fn vec_with_capacity( &self, cap: usize, ) -> GcVec<'_, Gc<ObjectType<'_>>>
Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more