pub struct GcScopeState<'s> { /* private fields */ }Implementations§
Source§impl<'s> GcScopeState<'s>
impl<'s> GcScopeState<'s>
pub fn new(heap: &'s mut GcHeap, partition_id: GcPartitionId) -> Self
pub fn partition_id(&self) -> GcPartitionId
pub fn heap(&self) -> &GcHeap
pub fn heap_mut(&mut self) -> &mut GcHeap
pub fn depth(&self) -> u8
pub fn count(&self) -> usize
Sourcepub fn parent(&self) -> Option<(&GcScopeState<'_>, u8)>
pub fn parent(&self) -> Option<(&GcScopeState<'_>, u8)>
get parent scope, and its level.
pub fn alloc_root<T: GcNode>( &self, payload: T, ) -> Result<GcRef<T>, (GcError, T)>
Sourcepub fn alloc_local<T: GcNode>(
&self,
payload: T,
) -> Result<GcRef<T>, (GcError, T)>
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}pub fn add_non_local(&self, node: NonNull<GcHead>) -> bool
pub fn get_promote(&self) -> Option<NonNull<GcHead>>
Sourcepub fn set_promote(&self, node: Option<NonNull<GcHead>>)
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.
Sourcepub fn flush(&self)
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}pub fn contains(&self, node: NonNull<GcHead>) -> bool
Trait Implementations§
Source§impl<'s> Debug for GcScopeState<'s>
impl<'s> Debug for GcScopeState<'s>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more