inner_loop.rs

Overview

This file implements the inner_loop function, which manages cross-thread reference data dependencies for block states within a node system. It continuously listens for incoming commands related to dependency tracking and updates the state of block processing accordingly. The logic ensures that blocks are marked as having all their cross-thread reference data available only when all their dependencies have been fulfilled.

The file primarily deals with managing references to blocks and their dependencies using weak references (Weak<BlockStateInner>) and strong references (Arc<BlockIdentifier>), facilitating automatic cleanup of unused block states and efficient dependency tracking.


Detailed Explanation

Function: inner_loop

pub(super) fn inner_loop(receiver_rx: InstrumentedReceiver<Command>)

Purpose

The inner_loop function operates a continuous event loop that processes commands received via an InstrumentedReceiver. These commands manage cross-thread reference data dependencies of blocks by tracking which blocks depend on others and when their dependencies have been satisfied.

Parameters

Behavior and Workflow

Return Value

Usage Example

// Assume `receiver` is an InstrumentedReceiver<Command> obtained from elsewhere
inner_loop(receiver);

Important Implementation Details


Interaction with Other System Components


Visual Diagram: inner_loop Function Workflow

flowchart TD
A[Start inner_loop] --> B[Receive Command from receiver_rx]
B -->|SetCrossThreadRefDataDependencies| C{Dependencies empty?}
C -->|Yes| D[Mark block_state as data available]
C -->|No| E[Insert block_state & dependencies into missing_dependencies]
B -->|NotifyCrossThreadRefDataPrepared| F[Remove expired entries]
F --> G[Remove prepared block_identifier from dependencies]
G --> H{Dependencies empty?}
H -->|Yes| I[Mark block_state as data available]
H -->|Yes| J[Remove block_state from missing_dependencies]
H -->|No| K[Continue]
B -->|Error (channel closed)| L[Exit loop]
D --> F
E --> F
I --> F
J --> F
K --> B

This flowchart shows the reception and processing of commands inside the inner_loop and the handling of dependencies for block states.


Additional Notes