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>)
| 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 | /// ``` |