rok::bare::gc
rok::bare::gc - keeping GC objects in place for raw pointers (stdlib
spec 1.6). A Pinned<T> from pin keeps the object holding T's
data where it is (rok_gc_pin, counted) until it is dropped, at the
end of its using block. GcPtr<T> is a managed reference to one T
on the GC heap (1.6.3); Weak<T> refers to a GcPtr<T>'s object
without keeping it alive (a WEAK_REF word, refs-lang 8.2.8).
Structs
GcPtr
pub struct GcPtr<T>A reference to a GC object holding one T (1.6.3). Copies share the
object. The collector traces it from every frame and object that
holds it and updates it when the object moves; a raw Ptr<T> to the
value exists only under a pin (Pinned<GcPtr<T>>::as_value_ptr).
pub const fn new(value: T) -> GcPtr<T>A new object holding
value.pub const fn get(self) -> TThe value.
pub const fn set(self, value: T)Replace the value; every copy sees it.
pub const fn same(self, other: GcPtr<T>) -> boolWhether
selfandotherare one object (identity, not value).
Trait implementations 2
impl<T> Pinnable for GcPtr<T>impl<T> !Sync for GcPtr<T>
Weak
pub struct Weak<T>A reference to a GcPtr<T>'s object that does not keep it alive
(refs-lang 8.2.8): once a collection finds the object unreachable
except through weak references, it frees it and every Weak to it
reads none from then on. For caches and observers.
pub fn new(target: GcPtr<T>) -> Weak<T>A weak reference to
target's object.pub fn get(self) -> GcPtr<T> | noneThe object,
noneonce it was collected.
Trait implementations 2
impl<T> !Sync for Weak<T>impl<T> !Send for Weak<T>
Pinned
pub struct Pinned<T>obj's data held in place (1.6.2).
pub fn obj(self) -> Tpub fn as_data_ptr(self) -> Ptr<T>The list's first element; dangling for an empty list.
pub fn as_data_many_ptr(self) -> ManyPtr<T>pub fn as_value_ptr(self) -> Ptr<T>The value in the pinned object.
pub fn as_bytes_ptr(self) -> ConstPtr<u8>The UTF-8 bytes (no NUL promised).
pub fn as_c_str(self) -> ConstPtr<c_char>The bytes as
c_chars; NUL termination is not promised (useffi::CString).
Trait implementations 1
impl<T> Drop for Pinned<T>
Traits
Pinnable
pub trait PinnableWhat pin keeps in place for a value: the GC object holding its
data, none when nothing can move (an empty list; a str, which
stays in place while the Pinned holding it is in scope, 2.15.2).
fn gc_object(self) -> GcBuf<u8> | none
Functions
collect
pub fn collect()A full collection now (it may move every unpinned object).
pin
pub fn pin<T: Pinnable>(obj: T) -> Pinned<T>Pin obj's data until the returned guard is dropped; bind it with
using (a Pinned dropped by nothing stays pinned).