MCPcopy Create free account
hub / github.com/RetypeOS/parcode / process_node

Function process_node

src/executor.rs:258–385  ·  view source on GitHub ↗
(
    scope: &rayon::Scope<'scope>,
    ctx: &'scope ExecutionContext<'a, 'scope, W>,
    node: &'scope Node<'a>,
)

Source from the content-addressed store, hash-verified

256/// It handles Serialization -> Compression -> Writing -> Notification.
257#[cfg(all(feature = "parallel", not(target_arch = "wasm32")))]
258fn process_node<'scope, 'a, W>(
259 scope: &rayon::Scope<'scope>,
260 ctx: &'scope ExecutionContext<'a, 'scope, W>,
261 node: &'scope Node<'a>,
262) where
263 W: Write + Send,
264{
265 // 0. Fast abort check
266 if ctx.should_abort() {
267 return;
268 }
269
270 // 1. Prepare data
271
272 let completed_children_raw = {
273 let lock = node
274 .completed_children
275 .lock()
276 .map_err(|_| ParcodeError::Internal("Node mutex poisoned".into()));
277 match lock {
278 Ok(mut guard) => std::mem::take(&mut *guard),
279 Err(e) => {
280 ctx.signal_error(e);
281 return;
282 }
283 }
284 };
285
286 let children_refs: Vec<ChildRef> = match completed_children_raw
287 .into_iter()
288 .map(|opt| opt.ok_or_else(|| ParcodeError::Internal("Missing child result".into())))
289 .collect()
290 {
291 Ok(v) => v,
292 Err(e) => {
293 ctx.signal_error(e);
294 return;
295 }
296 };
297
298 let is_chunkable = !children_refs.is_empty();
299
300 let raw_payload = match node.job.execute(&children_refs) {
301 Ok(bytes) => bytes,
302 Err(e) => {
303 ctx.signal_error(e);
304 return;
305 }
306 };
307
308 // 2&3. Compression and formatting
309
310 let config = node.job.config();
311 let compression_id = if ctx.use_compression && config.compression_id == 0 {
312 1
313 } else {
314 config.compression_id
315 };

Callers 1

execute_graph_parallelFunction · 0.85

Calls 15

should_abortMethod · 0.80
signal_errorMethod · 0.80
compress_appendMethod · 0.80
to_bytesMethod · 0.80
idMethod · 0.80
as_u8Method · 0.80
write_allMethod · 0.80
get_nodeMethod · 0.80
register_child_resultMethod · 0.80
capture_root_resultMethod · 0.80
is_emptyMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected