pub struct Graph<H: Host> {
pub data: H::Data,
/* private fields */
}Expand description
The nodes and the scheduler’s state.
Fields§
§data: H::DataThe host’s own state.
Implementations§
Source§impl<H: Host> Graph<H>
impl<H: Host> Graph<H>
Sourcepub fn compact(&mut self)
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.
Sourcepub fn signal(&mut self, value: H::Value, equals: Equals<H::Equals>) -> u32
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).
Sourcepub fn owned_signal(
&mut self,
value: H::Value,
equals: Equals<H::Equals>,
) -> u32
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).
Sourcepub fn computation(&mut self, kind: Kind, func: H::Func, value: H::Value) -> u32
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).
Sourcepub fn root(&mut self) -> u32
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).
Sourcepub fn context(&self) -> Option<Rc<Frame<H>>>
pub fn context(&self) -> Option<Rc<Frame<H>>>
The context frames the current owner sees, innermost first.
Sourcepub fn provide(
&mut self,
data: H::Context,
) -> Result<Option<Rc<Frame<H>>>, H::Context>
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).
Sourcepub fn live(&self, id: u32, generation: u32, mask: u32) -> bool
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.
Sourcepub fn generation(&self, id: u32) -> u32
pub fn generation(&self, id: u32) -> u32
Node id’s generation (for a handle).
Sourcepub fn parent(&self, id: u32) -> u32
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).
Sourcepub fn value(&self, id: u32) -> &H::Value
pub fn value(&self, id: u32) -> &H::Value
Node id’s value (untracked; a disposed memo keeps its last one).
Sourcepub fn replace_value(&mut self, id: u32, value: H::Value) -> H::Value
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]).
Sourcepub fn custom_equals(&self, id: u32) -> Option<&H::Equals>
pub fn custom_equals(&self, id: u32) -> Option<&H::Equals>
Node id’s custom comparison, if it has one.
Sourcepub fn set_equals(
&mut self,
id: u32,
equals: Equals<H::Equals>,
) -> Equals<H::Equals>
pub fn set_equals( &mut self, id: u32, equals: Equals<H::Equals>, ) -> Equals<H::Equals>
Node id’s comparison.
Sourcepub fn set_handle(&mut self, id: u32)
pub fn set_handle(&mut self, id: u32)
Marks node id as named by a handle.
Sourcepub fn held_by_handle(&self, id: u32) -> bool
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).
Sourcepub fn drop_handle(&mut self, id: u32) -> Option<Held<H>>
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).
Sourcepub fn set_owner(&mut self, owner: u32) -> u32
pub fn set_owner(&mut self, owner: u32) -> u32
Sets the current owner; returns the previous one.
Sourcepub fn enter_owner(&mut self, owner: u32) -> SavedOwner
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.
Sourcepub fn leave_owner(&mut self, saved: SavedOwner)
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).
Sourcepub fn set_listener(&mut self, listener: u32) -> u32
pub fn set_listener(&mut self, listener: u32) -> u32
Sets the current listener; returns the previous one.
Sourcepub fn is_live_owner(&self, id: u32) -> bool
pub fn is_live_owner(&self, id: u32) -> bool
Whether node id is a live owner (not disposed).
Sourcepub fn on_cleanup(&mut self, f: H::Cleanup) -> Result<(), H::Cleanup>
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).
Sourcepub fn remove_cleanup(
&mut self,
id: u32,
matches: impl Fn(&H::Cleanup) -> bool,
) -> Option<H::Cleanup>
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.
Sourcepub fn collecting_effects(&self) -> bool
pub fn collecting_effects(&self) -> bool
Whether effects are being collected (a new user effect waits for them).
Sourcepub fn reset_runs(&mut self)
pub fn reset_runs(&mut self)
A round ended: the runaway count starts over.
Sourcepub fn queue_effect(&mut self, id: u32)
pub fn queue_effect(&mut self, id: u32)
Queues user effect id after the render effects of the round.