[][src]Struct moving_gc_arena::Region

pub struct Region<T> { /* fields omitted */ }

The type of a collectable region.

This object can be used to allocate, collect, traverse and update the objects within it.

Access to the region is exposed through methods on the corresponding reference types, and requires references to this region in order to safely reference the data within. This ensures that garbage collections do not interrupt accesses and vice versa, and allows for a conservative compile-time check for uniqueness, rather than requiring use of an internal Cell type.

Since garbage collection is a property of the region, it is not statically checked for indices. Weak and Root will always be in sync with their source region, but raw indices Ix may be invalidated. Some methods (which necessarily take &mut self) may invalidate raw indices by moving the objects, such as for a garbage collection. These will be documented.

Methods

impl<T> Region<T>[src]

pub fn new() -> Self[src]

impl<T> Region<T>[src]

pub fn capacity(&self) -> usize[src]

Return the current capacity of this region. A collection won't be triggered by allocation unless the desired amount exceeds the capacity.

pub fn len(&self) -> usize[src]

Return the current number of entries in the region.

pub fn is_empty(&self) -> bool[src]

Returns true if there are currently no entries in this region.

impl<T: 'static + HasIx<T>> Region<T>[src]

pub fn ensure(&mut self, additional: usize)[src]

Ensure that the capacity supports new_elems more elements, collecting garbage if necessary.

pub fn alloc<F>(&mut self, make_t: F) -> MutEntry<T> where
    F: FnOnce(&Self) -> T, 
[src]

Allocate a new object, returning a temporary handle, which can be used to mutate the object and to get roots, weak pointers, and internal pointers to the object.

This may trigger a garbage collection and invalidate raw indices. As such, a function is used to generate the new value, which can query the state of the world post-collection.

pub fn gc(&mut self)[src]

Immediately trigger a standard garbage collection.

This invalidates raw indices.

use moving_gc_arena as gc;
let mut r = gc::Region::new();

r.alloc(|_|{()});
r.gc();
assert!(r.is_empty());

pub fn gc_into(self, other: &mut Region<T>)[src]

Move the elements of this region onto the end of another Region. This can trigger a collection in the other region if it must be re-allocated.

pub fn dfs_mut_cstack<'a, I, F>(&'a mut self, start: I, process: F) where
    T: HasIx<T>,
    F: FnMut(Ix<T>, &mut T),
    I: IntoIterator<Item = &'a Ix<T>>,
    I::IntoIter: Clone
[src]

Perform a depth-first search, applying a mutating function to each of the values passed over. This traversal uses the C stack, and so is subject to stack overflow, but can use any state for the traversal.

In order to ensure that this function performs well, the HasIx implementation for T must be deterministic: it should always return the same references. This is so that we can correctly maintain marking information.

There is currently no immutable variation on this function.

Trait Implementations

impl<T> Debug for Region<T>[src]

impl<T> Default for Region<T>[src]

Auto Trait Implementations

impl<T> !Send for Region<T>

impl<T> !Sync for Region<T>

impl<T> Unpin for Region<T> where
    T: Unpin

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, 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.