std::thread::spawn function
E440681
The std::thread::spawn function in Rust is a standard library API that creates and runs a new OS thread to execute a given closure concurrently with the current thread.
Observed surface forms (1)
| Surface form | Occurrences |
|---|---|
| std::thread::spawn | 0 |
Statements (42)
| Predicate | Object |
|---|---|
| instanceOf | Rust standard library function ⓘ |
| alternative | std::thread::Builder::spawn for configured threads ⓘ |
| belongsTo | std::thread namespace ⓘ |
| category | thread creation API ⓘ |
| commonPattern | move closures capturing data by value ⓘ |
| concurrencyModel | native OS threads ⓘ |
| coordination | joined via JoinHandle::join ⓘ |
| creates | operating system thread ⓘ |
| definedIn | Rust standard library NERFINISHED ⓘ |
| definedInModule | std::thread ⓘ |
| documentationUrl | https://doc.rust-lang.org/std/thread/fn.spawn.html ⓘ |
| effect | starts executing closure immediately after thread creation ⓘ |
| errorHandling | panics in spawned thread do not panic parent thread ⓘ |
| executes | closure ⓘ |
| executesConcurrentlyWith | current thread ⓘ |
| genericOver | closure return type T ⓘ |
| implementationDetail | may use platform-specific threading primitives ⓘ |
| introducedIn | Rust 1.0 stable NERFINISHED ⓘ |
| lifetimeRequirement | captured data must outlive spawned thread ⓘ |
| namespacePath | ::std::thread::spawn ⓘ |
| ownershipModel | moves captured values into new thread ⓘ |
| panicPropagation | panic payload is returned via JoinHandle::join ⓘ |
| programmingLanguage | Rust NERFINISHED ⓘ |
| requires |
closure argument to implement Send
ⓘ
closure return type T to implement Send ⓘ closure to have 'static lifetime ⓘ std crate to be available ⓘ |
| returns | std::thread::JoinHandle ⓘ |
| returnType | std::thread::JoinHandle<T> ⓘ |
| runs | closure to completion on spawned thread ⓘ |
| safety | safe Rust function ⓘ |
| scheduling | relies on operating system thread scheduler ⓘ |
| signatureExample | pub fn spawn<F, T>(f: F) -> JoinHandle<T> where F: FnOnce() -> T + Send + 'static, T: Send + 'static ⓘ |
| spawns | new thread of execution ⓘ |
| stability | stable API ⓘ |
| synchronization |
often used with Mutex and Arc
ⓘ
often used with channels ⓘ |
| threadModel | 1:1 mapping between Rust threads and OS threads ⓘ |
| threadType | non-detached by default ⓘ |
| usedFor |
background tasks
ⓘ
concurrent execution ⓘ parallel computation ⓘ |
Referenced by (1)
Full triples — surface form annotated when it differs from this entity's canonical label.