MCPcopy Create free account
hub / github.com/Bloom-Engine/engine / run_fn_captures_mutable_state

Function run_fn_captures_mutable_state

native/shared/src/renderer/graph.rs:446–464  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

444
445 #[test]
446 fn run_fn_captures_mutable_state() {
447 // Proves the RunFn / context model supports shared mutable
448 // data between passes — the real engine use case is writing
449 // to the encoder or the profiler.
450 let counter = Arc::new(Mutex::new(0));
451 let c1 = counter.clone();
452 let c2 = counter.clone();
453
454 let mut graph: Graph<'_, TestCtx> = Graph::new();
455 graph.push(PassNode::new("a", Box::new(move |_ctx| {
456 *c1.lock().unwrap() += 1;
457 })));
458 graph.push(PassNode::new("b", Box::new(move |_ctx| {
459 *c2.lock().unwrap() += 10;
460 })));
461 let mut ctx = Vec::new();
462 graph.execute(&mut ctx).unwrap();
463 assert_eq!(*counter.lock().unwrap(), 11);
464 }
465}

Callers

nothing calls this directly

Calls 3

cloneMethod · 0.80
executeMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected