Struct jrsonnet_gcmodule::ThreadedObjectSpace
source · [−]pub struct ThreadedObjectSpace { /* private fields */ }
Expand description
A collection of tracked ThreadedCc
objects
that can be garbage collected.
ThreadedObjectSpace
is similar to
ObjectSpace
but works with multi-thread.
Implementations
sourceimpl ThreadedObjectSpace
impl ThreadedObjectSpace
sourcepub fn count_tracked(&self) -> usize
pub fn count_tracked(&self) -> usize
Count objects tracked by this
ThreadedObjectSpace
.
sourcepub fn collect_cycles(&self) -> usize
pub fn collect_cycles(&self) -> usize
Collect cyclic garbage tracked by this
ThreadedObjectSpace
.
Return the number of objects collected.
sourcepub fn create<T: Trace + Send + Sync>(&self, value: T) -> ThreadedCc<T>
pub fn create<T: Trace + Send + Sync>(&self, value: T) -> ThreadedCc<T>
Constructs a new ThreadedCc<T>
in this
ThreadedObjectSpace
.
The returned object should not refer to
ThreadedCc<T>
created by a different
ThreadedObjectSpace
.
Otherwise the collector might fail to collect cycles.
The type T
needs to be Send + Sync
. This is because the
ThreadedObjectSpace
is
Send
and Sync
. The collector can run in a different
thread to access ThreadedCc<T>
, which needs to be
Send + Sync
to be safely accessed by the collector.
use gcmodule::{ThreadedObjectSpace, ThreadedCc, Cc};
let cc = Cc::new(5);
let space = ThreadedObjectSpace::default();
let tcc: ThreadedCc<Cc<_>> = space.create(cc);
Trait Implementations
sourceimpl Default for ThreadedObjectSpace
impl Default for ThreadedObjectSpace
sourcefn default() -> Self
fn default() -> Self
Constructs an empty ThreadedObjectSpace
.
impl Send for ThreadedObjectSpace
impl Sync for ThreadedObjectSpace
Auto Trait Implementations
impl !RefUnwindSafe for ThreadedObjectSpace
impl Unpin for ThreadedObjectSpace
impl !UnwindSafe for ThreadedObjectSpace
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more