pub struct Gc { /* private fields */ }
Expand description
A mark and sweep garbage collector.
Implementations§
source§impl Gc
impl Gc
sourcepub fn new(generation: Generation, memory_limit: usize) -> Gc
pub fn new(generation: Generation, memory_limit: usize) -> Gc
Constructs a new garbage collector
pub fn allocated_memory(&self) -> usize
pub fn set_memory_limit(&mut self, memory_limit: usize)
pub fn generation(&self) -> Generation
pub fn new_child_gc(&self) -> Gc
sourcepub unsafe fn alloc_and_collect<R, D>(
&mut self,
roots: R,
def: D
) -> Result<OwnedGcRef<'_, D::Value>>
pub unsafe fn alloc_and_collect<R, D>( &mut self, roots: R, def: D ) -> Result<OwnedGcRef<'_, D::Value>>
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.
pub fn alloc_owned<D>(&mut self, def: D) -> Result<OwnedGcRef<'_, D::Value>>
pub fn alloc_ignore_limit<D>(&mut self, def: D) -> GcRef<'_, D::Value>
pub unsafe fn check_collect<R>(&mut self, roots: R) -> boolwhere
R: Trace + CollectScope,
sourcepub unsafe fn collect<R>(&mut self, roots: R)where
R: Trace + CollectScope,
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.
sourcepub fn mark<T: ?Sized>(&mut self, value: &GcPtr<T>) -> bool
pub fn mark<T: ?Sized>(&mut self, value: &GcPtr<T>) -> bool
Marks the GcPtr Returns true if the pointer was already marked
sourcepub unsafe fn sweep(&mut self)
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
pub unsafe fn clear(&mut self)
Trait Implementations§
source§impl<'de, 'gc> DeserializeState<'de, DeSeed<'gc>> for Gc
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>,
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 SerializeState<SeSeed> for Gc
impl SerializeState<SeSeed> for Gc
source§fn serialize_state<__S>(
&self,
__serializer: __S,
__seed: &SeSeed
) -> Result<__S::Ok, __S::Error>where
__S: Serializer,
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> 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
§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn 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>
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)
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)
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.