Skip to main content

RegionTree

Struct RegionTree 

Source
pub struct RegionTree { /* private fields */ }
Expand description

Tree of regions enforcing structured concurrency (§4.11).

Every task/actor must be region-owned. The tree enforces INV-REGION-QUIESCENCE: no region closes until all children complete, all finalizers run, and all obligations resolve.

Implementations§

Source§

impl RegionTree

Source

pub fn new() -> Self

Create an empty region tree.

Source

pub fn create_root( &mut self, kind: RegionKind, cx: Cx<FullCaps>, ) -> Result<Region>

Create the root region.

Only one root region may exist. Returns an error if a root already exists.

Source

pub fn create_child( &mut self, parent: Region, kind: RegionKind, cx: Cx<FullCaps>, ) -> Result<Region>

Create a child region under the given parent.

Source

pub fn root(&self) -> Option<Region>

Root region, if created.

Source

pub fn kind(&self, id: Region) -> Option<RegionKind>

Query the kind of a region.

Source

pub fn state(&self, id: Region) -> Option<RegionState>

Query the state of a region.

Source

pub fn parent(&self, id: Region) -> Option<Option<Region>>

Query the parent of a region.

Source

pub fn children(&self, id: Region) -> Option<&[Region]>

List children of a region.

Source

pub fn cx(&self, id: Region) -> Option<Cx<FullCaps>>

Get a clone of the region’s Cx for cancellation inspection.

Source

pub fn active_tasks(&self, id: Region) -> usize

Active task count for a region.

Source

pub fn active_obligations(&self, id: Region) -> usize

Active obligation count for a region.

Source

pub fn register_task(&self, id: Region) -> Result<TaskHandle>

Register a task in a region, returning an RAII handle.

The task count is incremented; when the handle is dropped, it decrements. Returns Err(Busy) if the region is not RegionState::Open.

Source

pub fn register_obligation(&self, id: Region) -> Result<ObligationHandle>

Register an obligation in a region, returning an RAII handle.

Obligations can be registered while the region is Open or Closing (to allow in-flight work to create follow-up obligations during drain). Returns Err(Busy) if the region is RegionState::Closed.

Source

pub fn register_finalizer( &mut self, id: Region, finalizer: impl FnOnce() + Send + 'static, ) -> Result<()>

Register a finalizer callback to run during region close.

Source

pub fn begin_close(&mut self, id: Region) -> Result<()>

Begin closing a region: cancel its Cx and set state to Closing.

Recursively begins close on all descendant regions (parent-first cancellation propagation per INV-CANCEL-PROPAGATES).

Does NOT wait for quiescence. Use is_quiescent to poll, then complete_close to finalize.

Source

pub fn is_quiescent(&self, id: Region) -> bool

Check whether a region has reached quiescence.

A region is quiescent when:

  • all child regions are RegionState::Closed,
  • active task count is zero,
  • active obligation count is zero.
Source

pub fn complete_close(&mut self, id: Region) -> Result<()>

Complete region close: run finalizers and mark as RegionState::Closed.

Returns an error if the region is not quiescent.

Source

pub fn close_and_drain(&mut self, id: Region) -> Result<()>

Close a region and spin-wait until quiescent, then finalize.

This is the full close protocol: cancel → drain → finalize. Blocks the caller until INV-REGION-QUIESCENCE is satisfied. Children are drained bottom-up before the parent.

Trait Implementations§

Source§

impl Default for RegionTree

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, _span: NoopSpan) -> Self

Instruments this future with a span (no-op when disabled).
Source§

fn in_current_span(self) -> Self

Instruments this future with the current span (no-op when disabled).
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more