diff --git a/main/musegc/fn.collect.html b/main/musegc/fn.collect.html index bea3652..33f7cc0 100644 --- a/main/musegc/fn.collect.html +++ b/main/musegc/fn.collect.html @@ -1,5 +1,5 @@ collect in musegc - Rust -

Function musegc::collect

source ·
pub fn collect()
Expand description

Invokes the garbage collector.

+

Function musegc::collect

source ·
pub fn collect()
Expand description

Invokes the garbage collector.

This function will deadlock if any CollectionGuards are held by the current thread when invoked. If a guard is held, consider calling CollectionGuard::collect() instead.

diff --git a/main/musegc/fn.collected.html b/main/musegc/fn.collected.html index f4237bb..f605e31 100644 --- a/main/musegc/fn.collected.html +++ b/main/musegc/fn.collected.html @@ -1,5 +1,5 @@ collected in musegc - Rust -

Function musegc::collected

source ·
pub fn collected<R>(wrapped: impl FnOnce() -> R) -> R
Expand description

Executes wrapped with garbage collection available.

+

Function musegc::collected

source ·
pub fn collected<R>(wrapped: impl FnOnce() -> R) -> R
Expand description

Executes wrapped with garbage collection available.

This function installs a garbage collector for this thread, if needed. Repeated and nested calls are allowed.

Invoking CollectionGuard::acquire() within wrapped will return a diff --git a/main/musegc/index.html b/main/musegc/index.html index cc03178..9a59724 100644 --- a/main/musegc/index.html +++ b/main/musegc/index.html @@ -1,6 +1,6 @@ musegc - Rust

-

Crate musegc

source ·
Expand description

§musegc

+

Crate musegc

source ·
Expand description

§musegc

This name is a placeholder. The design of this crate has nothing to do with Muse, so naming it muse-gc seems misleading.

diff --git a/main/musegc/struct.CollectionGuard.html b/main/musegc/struct.CollectionGuard.html index 188de71..50fb5fa 100644 --- a/main/musegc/struct.CollectionGuard.html +++ b/main/musegc/struct.CollectionGuard.html @@ -1,5 +1,5 @@ CollectionGuard in musegc - Rust -

Struct musegc::CollectionGuard

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

A guard that prevents garbage collection while held.

+

Struct musegc::CollectionGuard

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

A guard that prevents garbage collection while held.

To perform garbage collection, all threads must be paused to be traced. A CollectionGuard allows the ability to read garbage-collectable data by ensuring the garbage collector can’t run while it exists.

@@ -15,26 +15,26 @@ IO, reading from a channel, or any other operation that may pause the current thread. CollectionGuard::while_unlocked() can be used to temporarily release a guard during a long operation.

-

Implementations§

source§

impl CollectionGuard

source

pub fn collect(&mut self)

Manually invokes the garbage collector.

+

Implementations§

source§

impl CollectionGuard

source

pub fn collect(&mut self)

Manually invokes the garbage collector.

This method temporarily releases this guard’s lock and waits for a garbage collection to run. If a garbage collection is already in progress, this function will return when the in-progress collection completes. Otherwise, the collector is started and this function waits until the collection finishes.

Finally, the guard is reacquired before returning.

-
source

pub fn yield_to_collector(&mut self)

Yield to the garbage collector, if needed.

+
source

pub fn yield_to_collector(&mut self)

Yield to the garbage collector, if needed.

This function will not yield unless the garbage collector is trying to acquire this thread’s lock. Because of this, it is a fairly efficient function to invoke. To minimize collection pauses, long-held guards should call this function regularly.

-
source

pub fn while_unlocked<R>(&mut self, unlocked: impl FnOnce() -> R) -> R

Executes unlocked while this guard is temporarily released.

-
source§

impl CollectionGuard

source

pub fn acquire() -> Self

Acquires a lock that prevents the garbage collector from running.

+
source

pub fn while_unlocked<R>(&mut self, unlocked: impl FnOnce() -> R) -> R

Executes unlocked while this guard is temporarily released.

+
source§

impl CollectionGuard

source

pub fn acquire() -> Self

Acquires a lock that prevents the garbage collector from running.

This guard is used to provide read-only access to garbage collected allocations.

§Panics

A panic will occur if this function is called outside of code executed by collected().

-

Trait Implementations§

source§

impl Drop for CollectionGuard

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where +

Trait Implementations§

source§

impl Drop for CollectionGuard

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

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<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<A> Cast for A

§

fn cast<To>(self) -> To
where diff --git a/main/musegc/struct.Ref.html b/main/musegc/struct.Ref.html index 046740d..8b4fd35 100644 --- a/main/musegc/struct.Ref.html +++ b/main/musegc/struct.Ref.html @@ -1,19 +1,21 @@ -Ref in musegc - Rust -

Struct musegc::Ref

source ·
pub struct Ref<T> { /* private fields */ }
Expand description

A reference to data stored in a garbage collector.

+Ref in musegc - Rust +

Struct musegc::Ref

source ·
pub struct Ref<T> { /* private fields */ }
Expand description

A reference to data stored in a garbage collector.

Unlike a Root<T>, this type is not guaranteed to have access to its underlying data. If no Collectable reachable via all active Roots marks this allocation, it will be collected.

Because of this, direct access to the data is not provided. To obtain a reference, call Ref::load().

-

Implementations§

source§

impl<T> Ref<T>
where - T: Collectable,

source

pub fn new(value: T, guard: &mut CollectionGuard) -> Self

Stores value in the garbage collector, returning a “weak” reference to +

Implementations§

source§

impl<T> Ref<T>
where + T: Collectable,

source

pub fn new(value: T, guard: &mut CollectionGuard) -> Self

Stores value in the garbage collector, returning a “weak” reference to it.

-
source

pub fn load<'guard>(&self, guard: &'guard CollectionGuard) -> Option<&'guard T>

Loads a reference to the underlying data. Returns None if the data has +

source

pub fn load<'guard>(&self, guard: &'guard CollectionGuard) -> Option<&'guard T>

Loads a reference to the underlying data. Returns None if the data has been collected and is no longer available.

-

Trait Implementations§

source§

impl<T> Clone for Ref<T>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T> Collectable for Ref<T>
where - T: Collectable,

source§

const MAY_CONTAIN_REFERENCES: bool = true

If true, this type may contain references and should have its trace() -function invoked during the collector’s “mark” phase.
source§

fn trace(&self, tracer: &mut Tracer<'_>)

Traces all refrences that this value references. Read more
source§

impl<T> Copy for Ref<T>

source§

impl<T> Send for Ref<T>
where - T: Collectable,

source§

impl<T> Sync for Ref<T>
where +

source

pub fn as_root(&self, guard: &CollectionGuard) -> Option<Root<T>>

Loads a root reference to the underlying data. Returns None if the +data has been collected and is no longer available.

+

Trait Implementations§

source§

impl<T> Clone for Ref<T>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T> Collectable for Ref<T>
where + T: Collectable,

source§

const MAY_CONTAIN_REFERENCES: bool = true

If true, this type may contain references and should have its trace() +function invoked during the collector’s “mark” phase.
source§

fn trace(&self, tracer: &mut Tracer<'_>)

Traces all refrences that this value references. Read more
source§

impl<T> Copy for Ref<T>

source§

impl<T> Send for Ref<T>
where + T: Collectable,

source§

impl<T> Sync for Ref<T>
where T: Collectable,

Auto Trait Implementations§

§

impl<T> Freeze for Ref<T>

§

impl<T> RefUnwindSafe for Ref<T>

§

impl<T> Unpin for Ref<T>

§

impl<T> UnwindSafe for Ref<T>

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<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 diff --git a/main/musegc/struct.Root.html b/main/musegc/struct.Root.html index 8b05e11..a0a7f79 100644 --- a/main/musegc/struct.Root.html +++ b/main/musegc/struct.Root.html @@ -1,21 +1,21 @@ Root in musegc - Rust -

Struct musegc::Root

source ·
pub struct Root<T>
where +

Struct musegc::Root

source ·
pub struct Root<T>
where T: Collectable,
{ /* private fields */ }
Expand description

A root reference to a T that has been allocated in the garbage collector.

This type behaves very similarly to Arc<T>. It is cheap-to-clone, utilizing atomic reference counting to track the number of root references currently exist to the underlying value.

While any root references exist for a given allocation, the garbage collector will not collect the allocation.

-

Implementations§

source§

impl<T> Root<T>
where - T: Collectable,

source

pub fn new(value: T, guard: &mut CollectionGuard) -> Self

Stores value in the garbage collector, returning a root reference to +

Implementations§

source§

impl<T> Root<T>
where + T: Collectable,

source

pub fn new(value: T, guard: &mut CollectionGuard) -> Self

Stores value in the garbage collector, returning a root reference to the data.

-
source

pub const fn downgrade(&self) -> Ref<T>

Returns a “weak” reference to this root.

-

Trait Implementations§

source§

impl<T> Collectable for Root<T>
where - T: Collectable,

source§

const MAY_CONTAIN_REFERENCES: bool = T::MAY_CONTAIN_REFERENCES

If true, this type may contain references and should have its trace() -function invoked during the collector’s “mark” phase.
source§

fn trace(&self, _tracer: &mut Tracer<'_>)

Traces all refrences that this value references. Read more
source§

impl<T> Deref for Root<T>
where - T: Collectable,

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<T> Drop for Root<T>
where - T: Collectable,

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<T> Send for Root<T>
where - T: Collectable,

source§

impl<T> Sync for Root<T>
where +

source

pub const fn downgrade(&self) -> Ref<T>

Returns a “weak” reference to this root.

+

Trait Implementations§

source§

impl<T> Collectable for Root<T>
where + T: Collectable,

source§

const MAY_CONTAIN_REFERENCES: bool = T::MAY_CONTAIN_REFERENCES

If true, this type may contain references and should have its trace() +function invoked during the collector’s “mark” phase.
source§

fn trace(&self, _tracer: &mut Tracer<'_>)

Traces all refrences that this value references. Read more
source§

impl<T> Deref for Root<T>
where + T: Collectable,

§

type Target = T

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<T> Drop for Root<T>
where + T: Collectable,

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<T> Send for Root<T>
where + T: Collectable,

source§

impl<T> Sync for Root<T>
where T: Collectable,

Auto Trait Implementations§

§

impl<T> Freeze for Root<T>

§

impl<T> RefUnwindSafe for Root<T>
where T: RefUnwindSafe,

§

impl<T> Unpin for Root<T>

§

impl<T> UnwindSafe for Root<T>
where T: RefUnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where diff --git a/main/musegc/struct.Tracer.html b/main/musegc/struct.Tracer.html index e499973..666f4ad 100644 --- a/main/musegc/struct.Tracer.html +++ b/main/musegc/struct.Tracer.html @@ -1,8 +1,8 @@ Tracer in musegc - Rust -

Struct musegc::Tracer

source ·
pub struct Tracer<'a> { /* private fields */ }
Expand description

A tracer for the garbage collector.

+

Struct musegc::Tracer

source ·
pub struct Tracer<'a> { /* private fields */ }
Expand description

A tracer for the garbage collector.

This type allows Collectable values to mark() any Ref<T>s they contain.

-

Implementations§

source§

impl<'a> Tracer<'a>

source

pub fn mark<T>(&mut self, collectable: Ref<T>)
where +

Implementations§

source§

impl<'a> Tracer<'a>

source

pub fn mark<T>(&mut self, collectable: Ref<T>)
where T: Collectable,

Marks collectable as being referenced, ensuring it is not garbage collected.

Auto Trait Implementations§

§

impl<'a> Freeze for Tracer<'a>

§

impl<'a> RefUnwindSafe for Tracer<'a>

§

impl<'a> Send for Tracer<'a>

§

impl<'a> Sync for Tracer<'a>

§

impl<'a> Unpin for Tracer<'a>

§

impl<'a> UnwindSafe for Tracer<'a>

Blanket Implementations§

source§

impl<T> Any for T
where diff --git a/main/musegc/trait.Collectable.html b/main/musegc/trait.Collectable.html index 5abda04..9f1a89d 100644 --- a/main/musegc/trait.Collectable.html +++ b/main/musegc/trait.Collectable.html @@ -1,20 +1,20 @@ Collectable in musegc - Rust -

Trait musegc::Collectable

source ·
pub trait Collectable: Send + Sync + 'static {
+    

Trait musegc::Collectable

source ·
pub trait Collectable: Send + Sync + 'static {
     const MAY_CONTAIN_REFERENCES: bool;
 
     // Required method
     fn trace(&self, tracer: &mut Tracer<'_>);
 }
Expand description

A type that can be garbage collected.

-

Required Associated Constants§

source

const MAY_CONTAIN_REFERENCES: bool

If true, this type may contain references and should have its trace() +

Required Associated Constants§

source

const MAY_CONTAIN_REFERENCES: bool

If true, this type may contain references and should have its trace() function invoked during the collector’s “mark” phase.

-

Required Methods§

source

fn trace(&self, tracer: &mut Tracer<'_>)

Traces all refrences that this value references.

+

Required Methods§

source

fn trace(&self, tracer: &mut Tracer<'_>)

Traces all refrences that this value references.

This function should invoke Tracer::mark() for each Ref<T> it contains. Failing to do so will allow the garbage collector to free the data, preventing the ability to load() the data in the future.

-

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T> Collectable for Vec<T>
where - T: Collectable,

source§

const MAY_CONTAIN_REFERENCES: bool = T::MAY_CONTAIN_REFERENCES

source§

fn trace(&self, tracer: &mut Tracer<'_>)

source§

impl<T, const N: usize> Collectable for [T; N]
where - T: Collectable,

source§

const MAY_CONTAIN_REFERENCES: bool = T::MAY_CONTAIN_REFERENCES

source§

fn trace(&self, tracer: &mut Tracer<'_>)

Implementors§

source§

impl<T> Collectable for Ref<T>
where - T: Collectable,

source§

impl<T> Collectable for Root<T>
where - T: Collectable,

source§

const MAY_CONTAIN_REFERENCES: bool = T::MAY_CONTAIN_REFERENCES

source§

impl<T> Collectable for T
where - T: ContainsNoCollectables + Send + Sync + 'static,

\ No newline at end of file +

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T> Collectable for Vec<T>
where + T: Collectable,

source§

const MAY_CONTAIN_REFERENCES: bool = T::MAY_CONTAIN_REFERENCES

source§

fn trace(&self, tracer: &mut Tracer<'_>)

source§

impl<T, const N: usize> Collectable for [T; N]
where + T: Collectable,

source§

const MAY_CONTAIN_REFERENCES: bool = T::MAY_CONTAIN_REFERENCES

source§

fn trace(&self, tracer: &mut Tracer<'_>)

Implementors§

source§

impl<T> Collectable for Ref<T>
where + T: Collectable,

source§

impl<T> Collectable for Root<T>
where + T: Collectable,

source§

const MAY_CONTAIN_REFERENCES: bool = T::MAY_CONTAIN_REFERENCES

source§

impl<T> Collectable for T
where + T: ContainsNoCollectables + Send + Sync + 'static,

\ No newline at end of file diff --git a/main/musegc/trait.ContainsNoCollectables.html b/main/musegc/trait.ContainsNoCollectables.html index 8e8e82d..da02e25 100644 --- a/main/musegc/trait.ContainsNoCollectables.html +++ b/main/musegc/trait.ContainsNoCollectables.html @@ -1,6 +1,6 @@ ContainsNoCollectables in musegc - Rust -
pub trait ContainsNoCollectables { }
Expand description

A type that can be garbage collected that cannot contain any Ref<T>s.

+
pub trait ContainsNoCollectables { }
Expand description

A type that can be garbage collected that cannot contain any Ref<T>s.

Types that implement this trait automatically implement Collectable. This trait reduces the boilerplate for implementing Collectable for self-contained types.

-

Implementations on Foreign Types§

source§

impl ContainsNoCollectables for i8

source§

impl ContainsNoCollectables for i16

source§

impl ContainsNoCollectables for i32

source§

impl ContainsNoCollectables for i64

source§

impl ContainsNoCollectables for i128

source§

impl ContainsNoCollectables for isize

source§

impl ContainsNoCollectables for u8

source§

impl ContainsNoCollectables for u16

source§

impl ContainsNoCollectables for u32

source§

impl ContainsNoCollectables for u64

source§

impl ContainsNoCollectables for u128

source§

impl ContainsNoCollectables for usize

Implementors§

\ No newline at end of file +

Implementations on Foreign Types§

source§

impl ContainsNoCollectables for i8

source§

impl ContainsNoCollectables for i16

source§

impl ContainsNoCollectables for i32

source§

impl ContainsNoCollectables for i64

source§

impl ContainsNoCollectables for i128

source§

impl ContainsNoCollectables for isize

source§

impl ContainsNoCollectables for u8

source§

impl ContainsNoCollectables for u16

source§

impl ContainsNoCollectables for u32

source§

impl ContainsNoCollectables for u64

source§

impl ContainsNoCollectables for u128

source§

impl ContainsNoCollectables for usize

Implementors§

\ No newline at end of file diff --git a/main/search-index.js b/main/search-index.js index 4c45fd6..0c2f655 100644 --- a/main/search-index.js +++ b/main/search-index.js @@ -1,5 +1,5 @@ var searchIndex = new Map(JSON.parse('[\ -["musegc",{"doc":"musegc","t":"KFKTFFFNNNNNNNNNNNNNNNNNNNHNHNNNNNNNNNNNNNNNNNNNNNMNNNNNNNNNNNNNNNN","n":["Collectable","CollectionGuard","ContainsNoCollectables","MAY_CONTAIN_REFERENCES","Ref","Root","Tracer","acquire","borrow","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","borrow_mut","cast","cast","cast","cast","cast_into","cast_into","cast_into","cast_into","clone","clone_into","collect","collect","collected","deref","downgrade","drop","drop","from","from","from","from","from_cast","from_cast","from_cast","from_cast","into","into","into","into","load","mark","new","new","to_owned","trace","trace","trace","try_from","try_from","try_from","try_from","try_into","try_into","try_into","try_into","type_id","type_id","type_id","type_id","while_unlocked","yield_to_collector"],"q":[[0,"musegc"],[67,"intentional::cast"],[68,"core::ops::function"],[69,"core::option"],[70,"core::result"],[71,"core::any"]],"d":["A type that can be garbage collected.","A guard that prevents garbage collection while held.","A type that can be garbage collected that cannot contain …","If true, this type may contain references and should have …","A reference to data stored in a garbage collector.","A root reference to a T that has been allocated in the …","A tracer for the garbage collector.","Acquires a lock that prevents the garbage collector from …","","","","","","","","","","","","","","","","","","","Invokes the garbage collector.","Manually invokes the garbage collector.","Executes wrapped with garbage collection available.","","Returns a “weak” reference to this root.","","","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","","","","","Calls U::from(self).","Calls U::from(self).","Calls U::from(self).","Calls U::from(self).","Loads a reference to the underlying data. Returns None if …","Marks collectable as being referenced, ensuring it is not …","Stores value in the garbage collector, returning a root …","Stores value in the garbage collector, returning a “weak…","","Traces all refrences that this value references.","","","","","","","","","","","","","","","Executes unlocked while this guard is temporarily released.","Yield to the garbage collector, if needed."],"i":[0,0,0,8,0,0,0,1,1,10,7,3,1,10,7,3,1,10,7,3,1,10,7,3,3,3,0,1,0,7,7,1,7,1,10,7,3,1,10,7,3,1,10,7,3,3,10,7,3,3,8,7,3,1,10,7,3,1,10,7,3,1,10,7,3,1,1],"f":"```````{{}b}{ce{}{}}0000000{cg{}{}{{d{e}}}}0001111{{{f{c}}}{{f{c}}}{}}{{ce}h{}{}}{{}h}{bh}{ec{}{{l{}{{j{c}}}}}}{{{n{c}}}eA`{}}{{{n{c}}}{{f{c}}}A`}3{{{n{c}}}hA`}{cc{}}0000000::::{{{f{c}}b}{{Ab{c}}}A`}{{Ad{f{c}}}hA`}{{cb}{{n{c}}}A`}{{cb}{{f{c}}}A`}>{{A`Ad}h}{{{n{c}}Ad}hA`}{{{f{c}}Ad}hA`}{c{{Af{e}}}{}{}}0000000{cAh{}}000{{be}c{}{{l{}{{j{c}}}}}}?","c":[],"p":[[5,"CollectionGuard",0],[10,"CastFrom",67],[5,"Ref",0],[1,"unit"],[17,"Output"],[10,"FnOnce",68],[5,"Root",0],[10,"Collectable",0],[6,"Option",69],[5,"Tracer",0],[6,"Result",70],[5,"TypeId",71]],"b":[]}]\ +["musegc",{"doc":"musegc","t":"KFKTFFFNNNNNNNNNNNNNNNNNNNNHNHNNNNNNNNNNNNNNNNNNNNNMNNNNNNNNNNNNNNNN","n":["Collectable","CollectionGuard","ContainsNoCollectables","MAY_CONTAIN_REFERENCES","Ref","Root","Tracer","acquire","as_root","borrow","borrow","borrow","borrow","borrow_mut","borrow_mut","borrow_mut","borrow_mut","cast","cast","cast","cast","cast_into","cast_into","cast_into","cast_into","clone","clone_into","collect","collect","collected","deref","downgrade","drop","drop","from","from","from","from","from_cast","from_cast","from_cast","from_cast","into","into","into","into","load","mark","new","new","to_owned","trace","trace","trace","try_from","try_from","try_from","try_from","try_into","try_into","try_into","try_into","type_id","type_id","type_id","type_id","while_unlocked","yield_to_collector"],"q":[[0,"musegc"],[68,"core::option"],[69,"intentional::cast"],[70,"core::ops::function"],[71,"core::result"],[72,"core::any"]],"d":["A type that can be garbage collected.","A guard that prevents garbage collection while held.","A type that can be garbage collected that cannot contain …","If true, this type may contain references and should have …","A reference to data stored in a garbage collector.","A root reference to a T that has been allocated in the …","A tracer for the garbage collector.","Acquires a lock that prevents the garbage collector from …","Loads a root reference to the underlying data. Returns None…","","","","","","","","","","","","","","","","","","","Invokes the garbage collector.","Manually invokes the garbage collector.","Executes wrapped with garbage collection available.","","Returns a “weak” reference to this root.","","","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","Returns the argument unchanged.","","","","","Calls U::from(self).","Calls U::from(self).","Calls U::from(self).","Calls U::from(self).","Loads a reference to the underlying data. Returns None if …","Marks collectable as being referenced, ensuring it is not …","Stores value in the garbage collector, returning a root …","Stores value in the garbage collector, returning a “weak…","","Traces all refrences that this value references.","","","","","","","","","","","","","","","Executes unlocked while this guard is temporarily released.","Yield to the garbage collector, if needed."],"i":[0,0,0,5,0,0,0,1,2,1,10,3,2,1,10,3,2,1,10,3,2,1,10,3,2,2,2,0,1,0,3,3,1,3,1,10,3,2,1,10,3,2,1,10,3,2,2,10,3,2,2,5,3,2,1,10,3,2,1,10,3,2,1,10,3,2,1,1],"f":"```````{{}b}{{{d{c}}b}{{h{{f{c}}}}}j}{ce{}{}}0000000{cg{}{}{{l{e}}}}0001111{{{d{c}}}{{d{c}}}{}}{{ce}n{}{}}{{}n}{bn}{ec{}{{Ab{}{{A`{c}}}}}}{{{f{c}}}ej{}}{{{f{c}}}{{d{c}}}j}3{{{f{c}}}nj}{cc{}}0000000::::{{{d{c}}b}{{h{c}}}j}{{Ad{d{c}}}nj}{{cb}{{f{c}}}j}{{cb}{{d{c}}}j}>{{jAd}n}{{{f{c}}Ad}nj}{{{d{c}}Ad}nj}{c{{Af{e}}}{}{}}0000000{cAh{}}000{{be}c{}{{Ab{}{{A`{c}}}}}}?","c":[],"p":[[5,"CollectionGuard",0],[5,"Ref",0],[5,"Root",0],[6,"Option",68],[10,"Collectable",0],[10,"CastFrom",69],[1,"unit"],[17,"Output"],[10,"FnOnce",70],[5,"Tracer",0],[6,"Result",71],[5,"TypeId",72]],"b":[]}]\ ]')); if (typeof exports !== 'undefined') exports.searchIndex = searchIndex; else if (window.initSearch) window.initSearch(searchIndex); diff --git a/main/src/musegc/lib.rs.html b/main/src/musegc/lib.rs.html index 94f9f70..06ad781 100644 --- a/main/src/musegc/lib.rs.html +++ b/main/src/musegc/lib.rs.html @@ -1553,8 +1553,23 @@

Files

1551 1552 1553 +1554 +1555 +1556 +1557 +1558 +1559 +1560 +1561 +1562 +1563 +1564 +1565 +1566 +1567 +1568 +1569
#![doc = include_str!("../README.md")]
-#![warn(missing_docs)]
 use core::slice;
 use std::alloc::{alloc_zeroed, Layout};
 use std::any::{Any, TypeId};
@@ -2444,10 +2459,7 @@ 

Files

} } - /// Loads a reference to the underlying data. Returns `None` if the data has - /// been collected and is no longer available. - #[must_use] - pub fn load<'guard>(&self, guard: &'guard CollectionGuard) -> Option<&'guard T> { + fn load_slot<'guard>(&self, guard: &'guard CollectionGuard) -> Option<&'guard RefCounted<T>> { let type_id = TypeId::of::<T>(); // SAFETY: The guard is always present except during allocation which // never invokes this function. @@ -2467,9 +2479,29 @@

Files

// SAFETY: The collector cannot collect data while `guard` is // active, so it is safe to create a reference to this data // bound to the guard's lifetime. - unsafe { &(*slot.value.get()).allocated.value }, + unsafe { &(*slot.value.get()).allocated }, ) } + + /// Loads a reference to the underlying data. Returns `None` if the data has + /// been collected and is no longer available. + #[must_use] + pub fn load<'guard>(&self, guard: &'guard CollectionGuard) -> Option<&'guard T> { + self.load_slot(guard).map(|allocated| &allocated.value) + } + + /// Loads a root reference to the underlying data. Returns `None` if the + /// data has been collected and is no longer available. + #[must_use] + pub fn as_root(&self, guard: &CollectionGuard) -> Option<Root<T>> { + self.load_slot(guard).map(|allocated| { + allocated.strong.fetch_add(1, Ordering::Acquire); + Root { + data: allocated, + reference: *self, + } + }) + } } impl<T> Clone for Ref<T> {