Spawn a new thread with closure The spawned thread may outlive the caller, so all variables captured must be moved or have static lifetime. thread::spawn(move || { // Code which captures from environment });
(f: F)
| 26 | /// }); |
| 27 | /// |
| 28 | pub fn spawn<F>(f: F) -> Result<(), SyscallError> |
| 29 | where |
| 30 | F: FnOnce() -> (), |
| 31 | F: Send + 'static, |
| 32 | { |
| 33 | launch(Box::new(f)) |
| 34 | } |
| 35 | |
| 36 | /// Launch a thread by calling the low-level syscalls |
| 37 | /// |