[][src]Struct shredder::Gc

pub struct Gc<T: Scan> { /* fields omitted */ }

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]

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]

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]

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]

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]

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]

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]

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]

impl<T: Scan> Debug for Gc<T>[src]

impl<T: Scan> Default for Gc<T> where
    T: Default + 'static, 
[src]

impl<T: Scan> Display for Gc<T> where
    T: Display
[src]

impl<T: Scan> Drop for Gc<T>[src]

impl<T: Scan> Eq for Gc<T> where
    T: Eq
[src]

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]

impl<T: Scan> Ord for Gc<T> where
    T: Ord
[src]

impl<T: Scan> PartialEq<Gc<T>> for Gc<T> where
    T: PartialEq
[src]

impl<T: Scan> PartialOrd<Gc<T>> for Gc<T> where
    T: PartialOrd
[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]

impl<T: Scan> Sync for Gc<T> where
    T: Sync + Send
[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for Gc<T>

impl<T> Unpin for Gc<T>

impl<T> !UnwindSafe for Gc<T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.