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

Function managed_worker

src/thread_pool.rs:2510–2519  ·  view source on GitHub ↗

This is the main loop for a worker thread. It's in charge of executing jobs. Operating on the principle that you should finish what you start before starting something new, workers will first execute their queue, then execute shared jobs, then pull new jobs from the injector.

(membership: Membership, halt: Arc<AtomicBool>)

Source from the content-addressed store, hash-verified

2508 /// let ok: Vec<i32> = vec![1, 2, 3];
2509 /// forte::scope(|scope| {
2510 /// let bad: Vec<i32> = vec![4, 5, 6];
2511 /// scope.spawn(|_: &Worker| {
2512 /// // Transfer ownership of `bad` into a local variable (also named `bad`).
2513 /// // This will force the closure to take ownership of `bad` from the environment.
2514 /// let bad = bad;
2515 /// println!("ok: {:?}", ok); // `ok` is only borrowed.
2516 /// println!("bad: {:?}", bad); // refers to our local variable, above.
2517 /// });
2518 ///
2519 /// scope.spawn(|_: &Worker| println!("ok: {:?}", ok)); // we too can borrow `ok`
2520 /// });
2521 /// # });
2522 /// ```

Callers 1

resizeMethod · 0.85

Calls 3

activateMethod · 0.80
yield_nowMethod · 0.80
waitMethod · 0.45

Tested by

no test coverage detected