pub struct MemoryApplier { /* private fields */ }Expand description
The stock Applier: it keeps nodes in memory under ids that stay stable for the life of the
node.
Implementations§
Source§impl MemoryApplier
impl MemoryApplier
Sourcepub fn slots_handle(&self) -> Rc<RefCell<SlotTable>>
pub fn slots_handle(&self) -> Rc<RefCell<SlotTable>>
The slot table that composition during layout writes to, shared with the layout pass that lends this applier.
Sourcepub fn scene_node_attached_to(
&mut self,
node_id: NodeId,
root: NodeId,
) -> Option<NodeId>
pub fn scene_node_attached_to( &mut self, node_id: NodeId, root: NodeId, ) -> Option<NodeId>
Resolves a scene-scope candidate the way structural records are
resolved: to its nearest non-virtual ancestor, and only while still
attached to root. A node detached after recording must not reach the
scoped scene update — an id the graph cannot resolve forces it to give
up and rebuild the whole scene.
Sourcepub fn scene_nodes_attached_to(
&mut self,
nodes: impl IntoIterator<Item = NodeId>,
root: NodeId,
) -> Vec<Option<NodeId>>
pub fn scene_nodes_attached_to( &mut self, nodes: impl IntoIterator<Item = NodeId>, root: NodeId, ) -> Vec<Option<NodeId>>
Self::scene_node_attached_to for each of nodes, in order, with
every ancestor looked up at most once: a batch costs the distinct
ancestors of its nodes, not each node’s depth.
Sourcepub fn scene_nodes_attached_to_into(
&mut self,
nodes: impl IntoIterator<Item = NodeId>,
root: NodeId,
output: &mut Vec<Option<NodeId>>,
scratch: &mut SceneNodeAttachmentScratch,
)
pub fn scene_nodes_attached_to_into( &mut self, nodes: impl IntoIterator<Item = NodeId>, root: NodeId, output: &mut Vec<Option<NodeId>>, scratch: &mut SceneNodeAttachmentScratch, )
Fills output with Self::scene_nodes_attached_to results, reusing
its storage and the ancestry cache in scratch across batches.
Each distinct ancestor is inspected at most once per call. The cache is cleared for each call, so graph mutations are observed by the next batch.
use cranpose_core::{MemoryApplier, NodeId, SceneNodeAttachmentScratch};
let mut applier = MemoryApplier::new();
let mut scratch = SceneNodeAttachmentScratch::default();
let mut attached: Vec<Option<NodeId>> = Vec::new();
let root = NodeId::default();
applier.scene_nodes_attached_to_into([], root, &mut attached, &mut scratch);
assert!(attached.is_empty());Sourcepub fn take_structural_change_parents_attached_to(
&mut self,
root: NodeId,
) -> Vec<NodeId> ⓘ
pub fn take_structural_change_parents_attached_to( &mut self, root: NodeId, ) -> Vec<NodeId> ⓘ
Drains the parents recorded via Applier::record_structural_change,
keeping only nodes still attached to root (a parent that was itself
removed is covered by its own surviving ancestor’s record). A virtual
parent — a subcompose slot wrapper the render graph never contains —
is reported as its nearest non-virtual ancestor: that is the node
whose graph child set the change altered, and an id the graph cannot
resolve would force the scoped scene update to give up and rebuild.
Sourcepub fn take_structural_change_parents_into(&mut self, output: &mut Vec<NodeId>)
pub fn take_structural_change_parents_into(&mut self, output: &mut Vec<NodeId>)
Takes the recorded structural-change candidates into reusable storage.
Candidates are not resolved or attachment-filtered; callers that route
them into scenes should use Self::scene_nodes_attached_to_into.
use cranpose_core::MemoryApplier;
let mut applier = MemoryApplier::new();
let mut nodes = Vec::new();
applier.take_structural_change_parents_into(&mut nodes);
assert!(nodes.is_empty());Sourcepub fn with_node<N: Node + 'static, R>(
&mut self,
id: NodeId,
f: impl FnOnce(&mut N) -> R,
) -> Result<R, NodeError>
pub fn with_node<N: Node + 'static, R>( &mut self, id: NodeId, f: impl FnOnce(&mut N) -> R, ) -> Result<R, NodeError>
Runs f on the node id as an N. Returns an error if the node does not exist or is not
an N.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the number of slots in the dense node table, both live and free.
Sourcepub fn tombstone_count(&self) -> usize
pub fn tombstone_count(&self) -> usize
Returns the number of free slots in the dense node table.
Sourcepub fn freelist_len(&self) -> usize
pub fn freelist_len(&self) -> usize
Returns the number of freed table slots that new nodes can reuse.
Sourcepub fn debug_recycled_node_count(&self) -> usize
pub fn debug_recycled_node_count(&self) -> usize
Returns the number of pooled recycled nodes of all types.
Sourcepub fn debug_recycled_node_count_for<N: Node + 'static>(&self) -> usize
pub fn debug_recycled_node_count_for<N: Node + 'static>(&self) -> usize
Returns the number of pooled recycled nodes of type N.
Sourcepub fn debug_stats(&self) -> MemoryApplierDebugStats
pub fn debug_stats(&self) -> MemoryApplierDebugStats
Returns the sizes of the applier’s tables, for leak and memory checks.
Sourcepub fn for_each_node_mut(&mut self, visit: impl FnMut(&mut dyn Node))
pub fn for_each_node_mut(&mut self, visit: impl FnMut(&mut dyn Node))
Calls visit with every live node, dense and high-id alike.
Sourcepub fn debug_live_node_heap_bytes(&self) -> usize
pub fn debug_live_node_heap_bytes(&self) -> usize
Returns the heap bytes that the live nodes take, including what they own.
Sourcepub fn debug_recycled_node_heap_bytes(&self) -> usize
pub fn debug_recycled_node_heap_bytes(&self) -> usize
Returns the heap bytes that the pooled recycled nodes take, including what they own.
Sourcepub fn set_runtime_handle(&mut self, handle: RuntimeHandle)
pub fn set_runtime_handle(&mut self, handle: RuntimeHandle)
Gives the applier the runtime of its composition, so code that runs during layout with only the applier in hand can reach the runtime.
Sourcepub fn clear_runtime_handle(&mut self)
pub fn clear_runtime_handle(&mut self)
Removes the runtime handle.
Sourcepub fn runtime_handle(&self) -> Option<RuntimeHandle>
pub fn runtime_handle(&self) -> Option<RuntimeHandle>
Returns the runtime handle set with set_runtime_handle, if any.
Trait Implementations§
Source§impl Applier for MemoryApplier
impl Applier for MemoryApplier
Source§fn record_structural_change(&mut self, parent_id: NodeId)
fn record_structural_change(&mut self, parent_id: NodeId)
parent_id’s child list changed structurally this frame
(insert, remove, move, or reparent). Incremental scene consumers drain
the recorded parents and re-patch those subtrees so removed nodes are
evicted from a persistent render graph even when the frame’s scene
update is otherwise scoped to unrelated dirty nodes.Source§fn node_generation(&self, id: NodeId) -> u32
fn node_generation(&self, id: NodeId) -> u32
Source§fn get_mut(&mut self, id: NodeId) -> Result<&mut dyn Node, NodeError>
fn get_mut(&mut self, id: NodeId) -> Result<&mut dyn Node, NodeError>
id for change, or an error if there is none.Source§fn remove(&mut self, id: NodeId) -> Result<(), NodeError>
fn remove(&mut self, id: NodeId) -> Result<(), NodeError>
id and the nodes below it.Source§fn begin_bubble_batch(&mut self)
fn begin_bubble_batch(&mut self)
Self::note_bubble_pass). Batches nest.Source§fn end_bubble_batch(&mut self)
fn end_bubble_batch(&mut self)
Self::begin_bubble_batch opened.Source§fn forget_bubble_passes(&mut self)
fn forget_bubble_passes(&mut self)
Source§fn note_bubble_pass(&mut self, id: NodeId, flags: u8) -> bool
fn note_bubble_pass(&mut self, id: NodeId, flags: u8) -> bool
flags passed the ancestor id.
true when one carrying all of them passed it earlier in the open
batch: that one marked every ancestor above id, so this one may
stop. An applier that keeps no notes answers false.Source§fn insert_with_id(
&mut self,
id: NodeId,
node: Box<dyn Node>,
) -> Result<(), NodeError>
fn insert_with_id( &mut self, id: NodeId, node: Box<dyn Node>, ) -> Result<(), NodeError>
Source§fn insert_recycled_node_or_create(
&mut self,
stable_id: NodeId,
node: Box<dyn Node>,
) -> RecycledNodeInsertion
fn insert_recycled_node_or_create( &mut self, stable_id: NodeId, node: Box<dyn Node>, ) -> RecycledNodeInsertion
Source§fn take_recycled_node(&mut self, key: TypeId) -> Option<RecycledNode>
fn take_recycled_node(&mut self, key: TypeId) -> Option<RecycledNode>
Source§fn set_recycled_node_origin(&mut self, id: NodeId, warm_origin: bool)
fn set_recycled_node_origin(&mut self, id: NodeId, warm_origin: bool)
Source§fn seed_recycled_node_shell(
&mut self,
key: TypeId,
recycle_pool_limit: Option<usize>,
shell: Box<dyn Node>,
)
fn seed_recycled_node_shell( &mut self, key: TypeId, recycle_pool_limit: Option<usize>, shell: Box<dyn Node>, )
Source§fn record_fresh_recyclable_creation(&mut self, key: TypeId)
fn record_fresh_recyclable_creation(&mut self, key: TypeId)
Source§fn clear_recycled_nodes(&mut self)
fn clear_recycled_nodes(&mut self)
Source§fn as_any(&self) -> &dyn Anywhere
Self: Sized,
fn as_any(&self) -> &dyn Anywhere
Self: Sized,
Any, for downcasting to its concrete type.Source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Any, for downcasting to its concrete type.