[−][src]Type Definition gcmodule::Cc
type Cc<T> = RawCc<T, ObjectSpace>;
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
:
ⓘThis example deliberately fails to compile
use std::ops::Deref; use gcmodule::Cc; let cc = Cc::new(5); std::thread::spawn(move || { println!("{}", cc.deref()); });
Methods
impl<T: Trace> Cc<T>
[src]
pub fn new(value: T) -> Cc<T>
[src]
Constructs a new Cc<T>
in a thread-local storage.
To collect cycles, use collect_thread_cycles
.
impl<T: Trace + Clone> Cc<T>
[src]
pub fn update_with(&mut self, update_func: impl FnMut(&mut T))
[src]
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.