Struct gluon_vm::gc::Gc

source ·
pub struct Gc { /* private fields */ }
Expand description

A mark and sweep garbage collector.

Implementations§

source§

impl Gc

source

pub fn new(generation: Generation, memory_limit: usize) -> Gc

Constructs a new garbage collector

source

pub fn allocated_memory(&self) -> usize

source

pub fn set_memory_limit(&mut self, memory_limit: usize)

source

pub fn generation(&self) -> Generation

source

pub fn new_child_gc(&self) -> Gc

source

pub unsafe fn alloc_and_collect<R, D>( &mut self, roots: R, def: D ) -> Result<OwnedGcRef<'_, D::Value>>
where R: Trace + CollectScope, D: DataDef + Trace, D::Value: Sized + Any,

Allocates a new object. If the garbage collector has hit the collection limit a collection will occur.

Unsafe since roots must be able to trace all accesible GcPtr values.

source

pub fn alloc<D>(&mut self, def: D) -> Result<GcRef<'_, D::Value>>
where D: DataDef, D::Value: Sized + Any,

Allocates a new object.

source

pub fn alloc_owned<D>(&mut self, def: D) -> Result<OwnedGcRef<'_, D::Value>>
where D: DataDef, D::Value: Sized + Any,

source

pub fn alloc_ignore_limit<D>(&mut self, def: D) -> GcRef<'_, D::Value>
where D: DataDef, D::Value: Sized + Any,

source

pub unsafe fn check_collect<R>(&mut self, roots: R) -> bool
where R: Trace + CollectScope,

source

pub unsafe fn collect<R>(&mut self, roots: R)
where R: Trace + CollectScope,

Does a mark and sweep collection by walking from roots. This function is unsafe since roots need to cover all reachable object.

source

pub fn mark<T: ?Sized>(&mut self, value: &GcPtr<T>) -> bool

Marks the GcPtr Returns true if the pointer was already marked

source

pub unsafe fn sweep(&mut self)

Clears out any unmarked pointers and resets marked pointers.

Unsafe as it is up to the caller to make sure that all reachable pointers have been marked

source

pub unsafe fn clear(&mut self)

Trait Implementations§

source§

impl Debug for Gc

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'de, 'gc> DeserializeState<'de, DeSeed<'gc>> for Gc

source§

fn deserialize_state<__D>( __seed: &mut DeSeed<'gc>, __deserializer: __D ) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserializes Self using seed and the deserializer
source§

impl Drop for Gc

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl SerializeState<SeSeed> for Gc

source§

fn serialize_state<__S>( &self, __serializer: __S, __seed: &SeSeed ) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serializes self

Auto Trait Implementations§

§

impl !RefUnwindSafe for Gc

§

impl Send for Gc

§

impl !Sync for Gc

§

impl Unpin for Gc

§

impl !UnwindSafe for Gc

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<Id> AsId<Id> for Id
where Id: ?Sized,

source§

fn as_id(&self) -> &Id

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
§

impl<Choices> CoproductSubsetter<CNil, HNil> for Choices

§

type Remainder = Choices

§

fn subset( self ) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>

Extract a subset of the possible types in a coproduct (or get the remaining possibilities) Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<D, T> FromPtr<D> for T

source§

unsafe fn make_ptr(_: D, ptr: *mut ()) -> *mut T

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.

§

impl<T, U, I> LiftInto<U, I> for T
where U: LiftFrom<T, I>,

§

fn lift_into(self) -> U

Performs the indexed conversion.
§

impl<Source> Sculptor<HNil, HNil> for Source

§

type Remainder = Source

§

fn sculpt(self) -> (HNil, <Source as Sculptor<HNil, HNil>>::Remainder)

Consumes the current HList and returns an HList with the requested shape. Read more
source§

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

§

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>,

§

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<T> Any for T
where T: Any,

source§

impl<T> Captures<'_> for T