fn run_loop<'b>(
        &mut self,
        starting_canister_id: CanisterId,
        metrics: &'b QueryHandlerMetrics,
        measurement_scope: &MeasurementScope<'b>,
    ) -> Result<WasmResult, UserError> {
        let measurement_scope =
            MeasurementScope::nested(&metrics.query_spawned_calls, measurement_scope);
        loop {
            if let Some(response) = self.outstanding_response.take() {
                debug!(self.log, "Executing response for {}", response.originator);
                // Any result returned by `handle_response` is a query context
                // terminating response and can be returned.
                if let Some(result) = self.handle_response(response, &measurement_scope) {
                    return result;
                }
                continue;
            }

            if let Some(request) = self.outstanding_requests.pop() {
                debug!(self.log, "Executing request for {}", request.receiver);
                if let Some(err) = self.handle_request(request, &measurement_scope) {
                    return Err(err);
                }
                continue;
            }

            // There are no outstanding requests and responses. The call
            // graph finished without producing a response.
            debug!(
                self.log,
                "Call graph for {} finished without result", starting_canister_id
            );
            return Err(UserError::new(
                ErrorCode::CanisterDidNotReply,
                format!(
                    "Canister {} did not reply to the call",
                    starting_canister_id
                ),
            ));
        }
    }
// Keep processing the call graph till a result is achieved or no more
// outstanding calls are left.
Keep processing the call graph till a result is achieved or no more
outstanding calls are left.
Keep processing the call graph till a result is achieved or no more outstanding calls are left .
fn run_loop<'b>(
        &mut self,
        starting_canister_id: CanisterId,
        metrics: &'b QueryHandlerMetrics,
        measurement_scope: &MeasurementScope<'b>,
    ) -> Result<WasmResult, UserError> {
        let measurement_scope =
            MeasurementScope::nested(&metrics.query_spawned_calls, measurement_scope);
        loop {
            if let Some(response) = self.outstanding_response.take() {
                debug!(self.log, "Executing response for {}", response.originator);
                // Any result returned by `handle_response` is a query context
                // terminating response and can be returned.
                if let Some(result) = self.handle_response(response, &measurement_scope) {
                    return result;
                }
                continue;
            }
            if let Some(request) = self.outstanding_requests.pop() {
                debug!(self.log, "Executing request for {}", request.receiver);
                if let Some(err) = self.handle_request(request, &measurement_scope) {
                    return Err(err);
                }
                continue;
            }
            // There are no outstanding requests and responses. The call
            // graph finished without producing a response.
            debug!(
                self.log,
                "Call graph for {} finished without result", starting_canister_id
            );
            return Err(UserError::new(
                ErrorCode::CanisterDidNotReply,
                format!(
                    "Canister {} did not reply to the call",
                    starting_canister_id
                ),
            ));
        }
    }
fn run_loop < ' b > ( & mut self , starting_canister_id : CanisterId , metrics : & ' b QueryHandlerMetrics , measurement_scope : & MeasurementScope < ' b > , ) -> Result < WasmResult , UserError > { let measurement_scope = MeasurementScope :: nested ( & metrics . query_spawned_calls , measurement_scope ) ; loop { if let Some ( response ) = self . outstanding_response . take ( ) { debug ! ( self log " " response originator ) ; // Any result returned by `handle_response` is a query context // terminating response and can be returned. if let Some ( result ) = self . handle_response ( response , & measurement_scope ) { return result ; } continue ; } if let Some ( request ) = self . outstanding_requests . pop ( ) { debug ! ( self log " " request receiver ) ; if let Some ( err ) = self . handle_request ( request , & measurement_scope ) { return Err ( err ) ; } continue ; } // There are no outstanding requests and responses. The call // graph finished without producing a response. debug ! ( self log " " starting_canister_id ) ; return Err ( UserError :: new ( ErrorCode :: CanisterDidNotReply , format ! ( " " starting_canister_id ) , ) ) ; } }
Keep processing the call graph till a result is achieved or no more
outstanding calls are left.
Keep processing the call graph till a result is achieved or no more outstanding calls are left .
&mut self
starting_canister_id
CanisterId
metrics
&'b QueryHandlerMetrics
measurement_scope
&MeasurementScope<'b>
&mut self
starting_canister_id
CanisterId
metrics
&'b QueryHandlerMetrics
measurement_scope
&MeasurementScope<'b>