Struct zerogc::Gc [−][src]
#[repr(C)]pub struct Gc<'gc, T: GcSafe + ?Sized + 'gc, Id: CollectorId> { /* fields omitted */ }
A garbage collected pointer to a value.
This is the equivalent of a garbage collected smart-pointer.
It’s so smart, you can even coerce it to a reference bound to the lifetime of the GarbageCollectorRef
.
However, all those references are invalidated by the borrow checker as soon as
your reference to the collector reaches a safepoint.
The objects can only survive garbage collection if they live in this smart-pointer.
The smart pointer is simply a guarantee to the garbage collector that this points to a garbage collected object with the correct header, and not some arbitrary bits that you’ve decided to heap allocate.
Implementations
impl<'gc, T: GcSafe + ?Sized + 'gc, Id: CollectorId> Gc<'gc, T, Id>
[src]
impl<'gc, T: GcSafe + ?Sized + 'gc, Id: CollectorId> Gc<'gc, T, Id>
[src]pub unsafe fn from_raw(id: Id, value: NonNull<T>) -> Self
[src]
Create a GC pointer from a raw ID/pointer pair
Safety
Undefined behavior if the underlying pointer is not valid and associated with the collector corresponding to the id.
pub fn value(&self) -> &'gc TⓘNotable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;
[src]
Notable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;
The value of the underlying pointer
pub unsafe fn as_raw_ptr(&self) -> *mut T
[src]
Cast this reference to a raw pointer
Safety
It’s undefined behavior to mutate the value. The pointer is only valid as long as the reference is.
pub fn create_handle<'a>(
&self
) -> <Id::System as GcHandleSystem<'gc, 'a, T>>::Handle where
Id::System: GcHandleSystem<'gc, 'a, T>,
T: GcErase<'a, Id> + 'a,
<T as GcErase<'a, Id>>::Erased: GcSafe + 'a,
[src]
&self
) -> <Id::System as GcHandleSystem<'gc, 'a, T>>::Handle where
Id::System: GcHandleSystem<'gc, 'a, T>,
T: GcErase<'a, Id> + 'a,
<T as GcErase<'a, Id>>::Erased: GcSafe + 'a,
Create a handle to this object, which can be used without a context
pub fn system(&self) -> &Id::System
[src]
Get a reference to the system
Safety
This is based on the assumption that a GcSystem must outlive all of the pointers it owns. Although it could be restricted to the lifetime of the CollectorId (in theory that may have an internal pointer) it will still live for ‘&self’.
pub fn collector_id(&self) -> Id
[src]
Get a copy of the collector’s id
The underlying collector it points to is not necessarily always valid
Trait Implementations
impl<'gc, T: GcSafe + ?Sized + 'gc, Id: CollectorId> Clone for Gc<'gc, T, Id>
[src]
impl<'gc, T: GcSafe + ?Sized + 'gc, Id: CollectorId> Clone for Gc<'gc, T, Id>
[src]fn clone(&self) -> Self
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<'gc, T: GcSafe + 'gc, Id: CollectorId> Deref for Gc<'gc, T, Id>
[src]
impl<'gc, T: GcSafe + 'gc, Id: CollectorId> Deref for Gc<'gc, T, Id>
[src]impl<'gc, O, V, Id> GcDirectBarrier<'gc, Gc<'gc, O, Id>> for Gc<'gc, V, Id> where
O: GcSafe + 'gc,
V: GcSafe + 'gc,
Id: CollectorId,
[src]
impl<'gc, O, V, Id> GcDirectBarrier<'gc, Gc<'gc, O, Id>> for Gc<'gc, V, Id> where
O: GcSafe + 'gc,
V: GcSafe + 'gc,
Id: CollectorId,
[src]unsafe fn write_barrier(&self, owner: &Gc<'gc, O, Id>, field_offset: usize)
[src]
impl<'gc, 'a, T, Id> GcErase<'a, Id> for Gc<'gc, T, Id> where
T: GcSafe + GcErase<'a, Id>,
<T as GcErase<'a, Id>>::Erased: GcSafe,
Id: CollectorId,
[src]
impl<'gc, 'a, T, Id> GcErase<'a, Id> for Gc<'gc, T, Id> where
T: GcSafe + GcErase<'a, Id>,
<T as GcErase<'a, Id>>::Erased: GcSafe,
Id: CollectorId,
[src]impl<'gc, 'new_gc, T, Id> GcRebrand<'new_gc, Id> for Gc<'gc, T, Id> where
T: GcSafe + GcRebrand<'new_gc, Id>,
<T as GcRebrand<'new_gc, Id>>::Branded: GcSafe,
Id: CollectorId,
[src]
impl<'gc, 'new_gc, T, Id> GcRebrand<'new_gc, Id> for Gc<'gc, T, Id> where
T: GcSafe + GcRebrand<'new_gc, Id>,
<T as GcRebrand<'new_gc, Id>>::Branded: GcSafe,
Id: CollectorId,
[src]Rebrand
impl<'gc, T: GcSafe + 'gc, Id: CollectorId> GcSafe for Gc<'gc, T, Id>
[src]
impl<'gc, T: GcSafe + 'gc, Id: CollectorId> GcSafe for Gc<'gc, T, Id>
[src]Double-indirection is completely safe
const NEEDS_DROP: bool
[src]
impl<'gc, T: GcSafe + PartialEq + 'gc, Id: CollectorId> PartialEq<Gc<'gc, T, Id>> for Gc<'gc, T, Id>
[src]
impl<'gc, T: GcSafe + PartialEq + 'gc, Id: CollectorId> PartialEq<Gc<'gc, T, Id>> for Gc<'gc, T, Id>
[src]impl<'gc, T: ?Sized, Id> Send for Gc<'gc, T, Id> where
T: GcSafe + Sync,
Id: CollectorId + Sync,
[src]
impl<'gc, T: ?Sized, Id> Send for Gc<'gc, T, Id> where
T: GcSafe + Sync,
Id: CollectorId + Sync,
[src]In order to send references between threads, the underlying type must be sync.
This is the same reason that Arc<T>: Send
requires T: Sync
impl<'gc, T: ?Sized, Id> Sync for Gc<'gc, T, Id> where
T: GcSafe + Sync,
Id: CollectorId + Sync,
[src]
impl<'gc, T: ?Sized, Id> Sync for Gc<'gc, T, Id> where
T: GcSafe + Sync,
Id: CollectorId + Sync,
[src]If the underlying type is Sync
, it’s safe
to share garbage collected references between threads.
The safety of the collector itself depends on whether CollectorId is Sync. If it is, the whole garbage collection implenentation should be as well.
Auto Trait Implementations
impl<'gc, T: ?Sized, Id> RefUnwindSafe for Gc<'gc, T, Id> where
Id: RefUnwindSafe,
T: RefUnwindSafe,
impl<'gc, T: ?Sized, Id> RefUnwindSafe for Gc<'gc, T, Id> where
Id: RefUnwindSafe,
T: RefUnwindSafe,
impl<'gc, T: ?Sized, Id> UnwindSafe for Gc<'gc, T, Id> where
Id: UnwindSafe,
T: RefUnwindSafe,
impl<'gc, T: ?Sized, Id> UnwindSafe for Gc<'gc, T, Id> where
Id: UnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]pub fn borrow(&self) -> &TⓘNotable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;
[src]
Notable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut TⓘNotable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;
[src]
Notable traits for &'_ mut R
impl<'_, R> Read for &'_ mut R where
R: Read + ?Sized, impl<'_, W> Write for &'_ mut W where
W: Write + ?Sized, impl<'_, I> Iterator for &'_ mut I where
I: Iterator + ?Sized, type Item = <I as Iterator>::Item;impl<'_, F> Future for &'_ mut F where
F: Future + Unpin + ?Sized, type Output = <F as Future>::Output;