Skip to main content

GcScopeState

Struct GcScopeState 

Source
pub struct GcScopeState<'s> { /* private fields */ }

Implementations§

Source§

impl<'s> GcScopeState<'s>

Source

pub fn new(heap: &'s mut GcHeap, partition_id: GcPartitionId) -> Self

Source

pub fn partition_id(&self) -> GcPartitionId

Source

pub fn heap(&self) -> &GcHeap

Source

pub fn heap_mut(&mut self) -> &mut GcHeap

Source

pub fn depth(&self) -> u8

Source

pub fn count(&self) -> usize

Source

pub fn parent(&self) -> Option<(&GcScopeState<'_>, u8)>

get parent scope, and its level.

Source

pub fn alloc_root<T: GcNode>( &self, payload: T, ) -> Result<GcRef<T>, (GcError, T)>

Source

pub fn alloc_local<T: GcNode>( &self, payload: T, ) -> Result<GcRef<T>, (GcError, T)>

alloc a local node in scope.

Examples found in repository?
examples/gc_node_usage.rs (line 36)
29fn alloc_static(
30    heap: &mut GcHeap,
31    scope: GcPartitionId,
32    value: i32,
33) -> GcResult<GcRef<StaticNode>> {
34    let ctx = GcScope::new(heap, scope);
35    let r = ctx
36        .alloc_local(StaticNode { _value: value })
37        .map_err(|(err, _)| err)?;
38    ctx.flush();
39    Ok(r)
40}
41
42fn alloc_other(heap: &mut GcHeap, scope: GcPartitionId, value: i32) -> GcResult<GcRef<OtherNode>> {
43    let ctx = GcScope::new(heap, scope);
44    let r = ctx
45        .alloc_local(OtherNode { _value: value })
46        .map_err(|(err, _)| err)?;
47    ctx.flush();
48    Ok(r)
49}
Source

pub fn add_non_local(&self, node: NonNull<GcHead>) -> bool

Source

pub fn get_promote(&self) -> Option<NonNull<GcHead>>

Source

pub fn set_promote(&self, node: Option<NonNull<GcHead>>)

Set a node to be promoted.

Promote means when the scope is dropped, the node will be added to upper scope.

Source

pub fn flush(&self)

clear and unprotect locals nodes in this scope; promote the result node to upper scope.

Examples found in repository?
examples/gc_node_usage.rs (line 38)
29fn alloc_static(
30    heap: &mut GcHeap,
31    scope: GcPartitionId,
32    value: i32,
33) -> GcResult<GcRef<StaticNode>> {
34    let ctx = GcScope::new(heap, scope);
35    let r = ctx
36        .alloc_local(StaticNode { _value: value })
37        .map_err(|(err, _)| err)?;
38    ctx.flush();
39    Ok(r)
40}
41
42fn alloc_other(heap: &mut GcHeap, scope: GcPartitionId, value: i32) -> GcResult<GcRef<OtherNode>> {
43    let ctx = GcScope::new(heap, scope);
44    let r = ctx
45        .alloc_local(OtherNode { _value: value })
46        .map_err(|(err, _)| err)?;
47    ctx.flush();
48    Ok(r)
49}
Source

pub fn contains(&self, node: NonNull<GcHead>) -> bool

Trait Implementations§

Source§

impl<'s> Debug for GcScopeState<'s>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'s> Drop for GcScopeState<'s>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'s> !Freeze for GcScopeState<'s>

§

impl<'s> !RefUnwindSafe for GcScopeState<'s>

§

impl<'s> !Send for GcScopeState<'s>

§

impl<'s> !Sync for GcScopeState<'s>

§

impl<'s> Unpin for GcScopeState<'s>

§

impl<'s> UnsafeUnpin for GcScopeState<'s>

§

impl<'s> !UnwindSafe for GcScopeState<'s>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.