[−][src]Struct shredder::Gc
A smart-pointer for data tracked by shredder
garbage collector
Implementations
impl<T: Scan> Gc<T>
[src]
pub fn new(v: T) -> Self where
T: 'static,
[src]
T: 'static,
Create a new Gc
containing the given data.
T: 'static
in order to create a Gc<T>
with this method.
If your T
is not static, consider new_with_finalizer
.
When this data is garbage collected, its drop
implementation will be run.
It is possible for this data not to be collected before the program terminates, or for the program to terminate before the background thread runs its destructor. So be careful when relying on this guarantee.
pub fn new_no_drop(v: T) -> Self
[src]
Create a new Gc
containing the given data. (But specifying not to run its destructor.)
This is useful because T: 'static
is no longer necessary!
When this data is garbage collected, its drop
implementation will NOT be run.
Be careful using this method! It can lead to memory leaks!
pub fn new_with_finalizer(v: T) -> Self where
T: Finalize,
[src]
T: Finalize,
Create a new Gc
containing the given data. (But specifying to call finalize
on it
instead of running its destructor.)
This is useful because T: 'static
is no longer necessary!
As long as finalize
does what you think it does, this is probably what you want for
non-'static data!
It is possible for this data not to be collected before the program terminates, or for
the program to terminate before the background thread runs finalize
. So be careful!
#[must_use]pub fn get(&self) -> GcGuard<T>
[src]
get
lets you get a GcGuard
, which will deref to the underlying data.
get
is used to get a GcGuard
. This is usually what you want when accessing non-Sync
data in a Gc
. The API is very analogous to the Mutex
API. It may block if the data is
being scanned
impl<T: Scan + 'static> Gc<RefCell<T>>
[src]
#[must_use]pub fn borrow(&self) -> GcRef<T>
[src]
Call the underlying borrow
method on the RefCell
.
This is just a nice method so you don't have to call get
manually.
pub fn try_borrow(&self) -> Result<GcRef<T>, BorrowError>
[src]
Call the underlying try_borrow
method on the RefCell
.
This is just a nice method so you don't have to call get
manually.
Errors
Propagates a BorrowError
if the underlying RefCell
is already borrowed mutably
#[must_use]pub fn borrow_mut(&self) -> GcRefMut<T>
[src]
Call the underlying borrow_mut
method on the RefCell
.
This is just a nice method so you don't have to call get
manually.
pub fn try_borrow_mut(&self) -> Result<GcRefMut<T>, BorrowMutError>
[src]
Call the underlying try_borrow_mut
method on the RefCell
.
This is just a nice method so you don't have to call get
manually.
Errors
Propagates a BorrowError
if the underlying RefCell
is already borrowed
impl<T: Scan + 'static> Gc<Mutex<T>>
[src]
pub fn lock(&self) -> Result<GcMutexGuard<T>, GcPoisonError<GcMutexGuard<T>>>
[src]
Call the underlying lock
method on the inner Mutex
This is just a nice method so you don't have to get
manually
Errors
Returns a GcPoisonError
if the underlying .lock
method returns a poison error.
You may use into_inner
in order to recover the guard from that error.
pub fn try_lock(
&self
) -> Result<GcMutexGuard<T>, GcTryLockError<GcMutexGuard<T>>>
[src]
&self
) -> Result<GcMutexGuard<T>, GcTryLockError<GcMutexGuard<T>>>
Call the underlying try_lock
method on the inner Mutex
This is just a nice method so you don't have to get
manually
Errors
Returns a GcTryLockError
if the underlying .try_lock
method returns an error
impl<T: Scan + 'static> Gc<RwLock<T>>
[src]
pub fn read(
&self
) -> Result<GcRwLockReadGuard<T>, GcPoisonError<GcRwLockReadGuard<T>>>
[src]
&self
) -> Result<GcRwLockReadGuard<T>, GcPoisonError<GcRwLockReadGuard<T>>>
Call the underlying read
method on the inner RwLock
This is just a nice method so you don't have to get
manually
Errors
Returns a GcPoisonError
if the underlying read
method returns a poison error.
You may use into_inner
in order to recover the guard from that error.
pub fn write(
&self
) -> Result<GcRwLockWriteGuard<T>, GcPoisonError<GcRwLockWriteGuard<T>>>
[src]
&self
) -> Result<GcRwLockWriteGuard<T>, GcPoisonError<GcRwLockWriteGuard<T>>>
Call the underlying write
method on the inner RwLock
This is just a nice method so you don't have to get
manually
Errors
Returns a GcPoisonError
if the underlying write
method returns a poison error.
You may use into_inner
in order to recover the guard from that error.
pub fn try_read(
&self
) -> Result<GcRwLockReadGuard<T>, GcTryLockError<GcRwLockReadGuard<T>>>
[src]
&self
) -> Result<GcRwLockReadGuard<T>, GcTryLockError<GcRwLockReadGuard<T>>>
Call the underlying try_read
method on the inner RwLock
This is just a nice method so you don't have to get
manually
Errors
Returns a GcTryLockError
if the underlying try_read
method returns an error
pub fn try_write(
&self
) -> Result<GcRwLockWriteGuard<T>, GcTryLockError<GcRwLockWriteGuard<T>>>
[src]
&self
) -> Result<GcRwLockWriteGuard<T>, GcTryLockError<GcRwLockWriteGuard<T>>>
Call the underlying try_write
method on the inner RwLock
This is just a nice method so you don't have to get
manually
Errors
Returns a GcTryLockError
if the underlying try_write
method returns an error
Trait Implementations
impl<T: Scan> Clone for Gc<T>
[src]
#[must_use]fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: Scan> Debug for Gc<T>
[src]
impl<T: Scan> Default for Gc<T> where
T: Default + 'static,
[src]
T: Default + 'static,
impl<T: Scan> Display for Gc<T> where
T: Display,
[src]
T: Display,
impl<T: Scan> Drop for Gc<T>
[src]
impl<T: Scan> Eq for Gc<T> where
T: Eq,
[src]
T: Eq,
impl<T: Scan> Finalize for Gc<T>
[src]
impl<T: Scan> GcSafe for Gc<T>
[src]
impl<T: Scan> Hash for Gc<T> where
T: Hash,
[src]
T: Hash,
fn hash<H: Hasher>(&self, state: &mut H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T: Scan> Ord for Gc<T> where
T: Ord,
[src]
T: Ord,
#[must_use]fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<T: Scan> PartialEq<Gc<T>> for Gc<T> where
T: PartialEq,
[src]
T: PartialEq,
#[must_use]fn eq(&self, other: &Self) -> bool
[src]
#[must_use]fn ne(&self, other: &Self) -> bool
[src]
impl<T: Scan> PartialOrd<Gc<T>> for Gc<T> where
T: PartialOrd,
[src]
T: PartialOrd,
#[must_use]fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Self) -> bool
[src]
#[must_use]fn le(&self, other: &Self) -> bool
[src]
#[must_use]fn gt(&self, other: &Self) -> bool
[src]
#[must_use]fn ge(&self, other: &Self) -> bool
[src]
impl<T: Scan> Pointer for Gc<T>
[src]
impl<T: Scan> Scan for Gc<T>
[src]
impl<T: Scan> Send for Gc<T> where
T: Sync + Send,
[src]
T: Sync + Send,
impl<T: Scan> Sync for Gc<T> where
T: Sync + Send,
[src]
T: Sync + Send,
Auto Trait Implementations
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,