Skip to main content

Graph

Struct Graph 

Source
pub struct Graph<H: Host> {
    pub data: H::Data,
    /* private fields */
}
Expand description

The nodes and the scheduler’s state.

Fields§

§data: H::Data

The host’s own state.

Implementations§

Source§

impl<H: Host> Graph<H>

Source

pub fn new(data: H::Data) -> Self

An empty graph with the host’s state data.

Source

pub fn compact(&mut self)

Gives back the slots a large tree used once it is gone: drops the free slots at the end of the arena, then lets the arena’s spare room go. Freed slots are reused lowest first from then on, so those near the end empty out and go at the next compaction. Call when no round runs (the engine does when it is idle); a no-op otherwise.

Source

pub fn signal(&mut self, value: H::Value, equals: Equals<H::Equals>) -> u32

A new signal holding value (owned), compared by equals, named by a handle (freed with Graph::drop_handle).

Source

pub fn owned_signal( &mut self, value: H::Value, equals: Equals<H::Equals>, ) -> u32

A new signal holding value (owned), compared by equals, owned by the current owner: disposed with it (with no owner, it lives as long as the graph).

Source

pub fn computation(&mut self, kind: Kind, func: H::Func, value: H::Value) -> u32

Makes a computation running func under the current owner, with first value value; it has not run yet (update_computation).

Source

pub fn root(&mut self) -> u32

A new root owner under the current owner (context passes through it; the current owner does not own it).

Source

pub fn context_of(&self, owner: u32) -> Option<Rc<Frame<H>>>

The context frames owner owner sees, innermost first (none for NONE, UNOWNED and DISPOSED).

Source

pub fn context(&self) -> Option<Rc<Frame<H>>>

The context frames the current owner sees, innermost first.

Source

pub fn provide( &mut self, data: H::Context, ) -> Result<Option<Rc<Frame<H>>>, H::Context>

Sets a context frame on the current owner: it and what is made under it from now on see data. Returns the frame it replaced, to drop once the graph is no longer borrowed (None without an owner, and data comes back).

Source

pub fn live(&self, id: u32, generation: u32, mask: u32) -> bool

Whether handle (id, generation) still names its node; mask keeps the bits of the generation a handle holds.

Source

pub fn slots(&self) -> (usize, usize)

The slots in use and all slots (freed ones are reused).

Source

pub fn generation(&self, id: u32) -> u32

Node id’s generation (for a handle).

Source

pub fn parent(&self, id: u32) -> u32

The owner of node id (for a root, the slot it was made under: an owner that re-makes its root in place, as a region does, is found through it again).

Source

pub fn kind(&self, id: u32) -> Kind

Node id’s kind.

Source

pub fn disposed(&self, id: u32) -> bool

Whether node id was disposed.

Source

pub fn value(&self, id: u32) -> &H::Value

Node id’s value (untracked; a disposed memo keeps its last one).

Source

pub fn replace_value(&mut self, id: u32, value: H::Value) -> H::Value

Replaces node id’s value with value, without notifying: the old one, to change and write back ([write]).

Source

pub fn custom_equals(&self, id: u32) -> Option<&H::Equals>

Node id’s custom comparison, if it has one.

Source

pub fn set_equals( &mut self, id: u32, equals: Equals<H::Equals>, ) -> Equals<H::Equals>

Node id’s comparison.

Source

pub fn set_handle(&mut self, id: u32)

Marks node id as named by a handle.

Source

pub fn held_by_handle(&self, id: u32) -> bool

Whether node id’s handle owns what the node holds: it is freed with the handle (Self::drop_handle), as a signal or a disposed computation is. A live computation belongs to its owner and outlives its handle, so what it holds is not the handle’s (a garbage collector must not count it among the handle’s children); so does one being disposed, until that ends (dispose frees it then).

Source

pub fn drop_handle(&mut self, id: u32) -> Option<Held<H>>

The handle of node id went: a signal, or a disposed computation, is freed now (what it held comes back, to free once the graph is no longer borrowed).

Source

pub fn owner(&self) -> u32

The current owner.

Source

pub fn set_owner(&mut self, owner: u32) -> u32

Sets the current owner; returns the previous one.

Source

pub fn enter_owner(&mut self, owner: u32) -> SavedOwner

Makes owner current for a run; returns the previous owner, to put back with Self::leave_owner.

Source

pub fn leave_owner(&mut self, saved: SavedOwner)

Puts back the owner Self::enter_owner saved: DISPOSED if it was disposed meanwhile (its slot may name another node now).

Source

pub fn listener(&self) -> u32

The current listener (what reads track into).

Source

pub fn set_listener(&mut self, listener: u32) -> u32

Sets the current listener; returns the previous one.

Source

pub fn has_owner(&self) -> bool

Whether a live owner owns what runs now.

Source

pub fn is_live_owner(&self, id: u32) -> bool

Whether node id is a live owner (not disposed).

Source

pub fn on_cleanup(&mut self, f: H::Cleanup) -> Result<(), H::Cleanup>

Adds cleanup f to the current owner; gives it back without one (and under DISPOSED, where the host runs it at once).

Source

pub fn remove_cleanup( &mut self, id: u32, matches: impl Fn(&H::Cleanup) -> bool, ) -> Option<H::Cleanup>

Removes from owner id the first cleanup matches accepts, which then never runs: what it was to undo ended by itself.

Source

pub fn in_round(&self) -> bool

Whether a round is running (its end reports errors).

Source

pub fn collecting_effects(&self) -> bool

Whether effects are being collected (a new user effect waits for them).

Source

pub fn reset_runs(&mut self)

A round ended: the runaway count starts over.

Source

pub fn queue_effect(&mut self, id: u32)

Queues user effect id after the render effects of the round.

Source

pub fn free_all(&mut self, h: H)

Frees every value the graph holds, for a teardown (no host code runs from here on but releasing).

Auto Trait Implementations§

§

impl<H> !Send for Graph<H>

§

impl<H> !Sync for Graph<H>

§

impl<H> Forget for Graph<H>

§

impl<H> Freeze for Graph<H>
where *const u8 is !null: Freeze, PhantomData<Node<H>>: Freeze, PhantomData<u32>: Freeze, PhantomData<(u32, Vec<(u32, u32)>)>: Freeze, <H as Host>::Data: Freeze,

§

impl<H> Move for Graph<H>

§

impl<H> RefUnwindSafe for Graph<H>

§

impl<H> Unpin for Graph<H>
where *const u8 is !null: Unpin, <H as Host>::Value: Unpin, <H as Host>::Func: Unpin, <H as Host>::Equals: Unpin, <H as Host>::Cleanup: Unpin, Rc<Frame<H>>: Unpin, <H as Host>::Data: Unpin,

§

impl<H> UnsafeUnpin for Graph<H>

§

impl<H> UnwindSafe for Graph<H>
where RawVecInner: UnwindSafe, <H as Host>::Value: UnwindSafe, <H as Host>::Func: UnwindSafe, <H as Host>::Equals: UnwindSafe, <H as Host>::Cleanup: UnwindSafe, Rc<Frame<H>>: UnwindSafe, HashMap<u32, Vec<(u32, u32)>, FxBuildHasher>: UnwindSafe, <H as Host>::Data: UnwindSafe,

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.