Type Definition jrsonnet_gcmodule::Cc

source ·
pub type Cc<T> = RawCc<T, ObjectSpace>;
Expand description

A single-threaded reference-counting pointer that integrates with cyclic garbage collection.

See module level documentation for more details.

Cc is not thread-safe. It does not implement Send or Sync:

use std::ops::Deref;
use gcmodule::Cc;
let cc = Cc::new(5);
std::thread::spawn(move || {
    println!("{}", cc.deref());
});

Implementations§

source§

impl<T: Trace> Cc<T>

source

pub fn new(value: T) -> Cc<T>

Constructs a new Cc<T> in a thread-local storage.

To collect cycles, use collect_thread_cycles.

source§

impl<T: Trace + Clone> Cc<T>

source

pub fn update_with(&mut self, update_func: impl FnMut(&mut T))

Update the value T in a copy-on-write way.

If the ref count is 1, the value is updated in-place. Otherwise a new Cc<T> will be created.

Trait Implementations§

source§

impl<T: Default + Trace> Default for Cc<T>

source§

fn default() -> Cc<T>

Returns the “default value” for a type. Read more
source§

impl<T: ?Sized> Deref for Cc<T>

§

type Target = T

The resulting type after dereferencing.
source§

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

Dereferences the value.
source§

impl<T: Trace> Trace for Cc<T>

source§

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

Define how to visit values referred by this value. Read more
source§

fn is_type_tracked() -> bool

Whether this type should be tracked by the collector. Read more
source§

impl Trace for Cc<dyn Trace>

source§

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

Define how to visit values referred by this value. Read more
source§

fn is_type_tracked() -> bool

Whether this type should be tracked by the collector. Read more