MCPcopy Create free account
hub / github.com/NthTensor/Forte / broadcast

Function broadcast

src/thread_pool.rs:2454–2463  ·  view source on GitHub ↗

Runs an operation on multiple threads and returns a vector of results. When executed on a thread that is currently registered as a worker (i.e. the closure inside [`Membership::activate`], [`ThreadPool::with_worker`], or similar) this is able to look up that registration and find the worker and thread-pool implicitly. If not called within a thread pool, this uses the [`DEFAULT_POOL`]. If you ha

(f: F)

Source from the content-addressed store, hash-verified

2452 // Wrap the operation in an `Arc` so each per-member job can own an
2453 // independent, `'static` reference to it. We must *not* let a job
2454 // capture a borrow of `f`: `spawn_broadcast` does not wait, so `f`
2455 // would be dropped while jobs are still queued or running on other
2456 // threads.
2457 let f = Arc::new(f);
2458
2459 // Send the broadcast to each member, and wake them up.
2460 for (i, member_index) in members.iter_bits().enumerate() {
2461 let func = Arc::clone(&f);
2462 // Run the operation. A panic from it has nowhere to propagate,
2463 // and must not unwind into the executing worker, so it is caught
2464 // and passed to the pool's panic handler.
2465 let op = move |worker: &Worker| {
2466 let result = unwind::halt_unwinding(|| {

Callers

nothing calls this directly

Calls 1

broadcastMethod · 0.80

Tested by

no test coverage detected