type StrongRef = Arc<()>;Expand description
The strong reference count of one node is the number of ResHandles that
name it plus the number of nodes built from it, which is exactly what
Arc already counts.
Every node holds a Weak handle to the Arc<()> token its ids
carry, so cloning an id clones the token — one more strong reference — and
dropping it releases the token, with no counter of our own to keep. A
dependent holds one more clone on behalf of each dependency it declared, so
each of a resource’s dependents counts towards keeping it alive. Cloning the
Weak in the node takes no reference, so ResourceGraph::maintain can
read the live count back without keeping the node alive itself.
The token is an Arc and not an Rc because an id may cross to another
thread even though the graph it names does not: an Arc makes every id
Send and Sync, so one can be handed to a worker while the graph stays
where it is. The graph itself is not Send: it holds wgpu handles and runs
its recipes, so it stays on the one thread that owns the world it sits in.
Aliased Type§
struct StrongRef { /* private fields */ }