Struct std::thread::Builder
[−]
[src]
pub struct Builder { // some fields omitted }
Thread configuration. Provides detailed control over the properties and behavior of new threads.
Methods
impl Builder
fn new() -> Builder
Generates the base configuration for spawning a thread, from which configuration methods can be chained.
fn name(self, name: String) -> Builder
Names the thread-to-be. Currently the name is used for identification only in panic messages.
fn stack_size(self, size: usize) -> Builder
Sets the size of the stack for the new thread.
fn spawn<F, T>(self, f: F) -> Result<JoinHandle<T>> where F: FnOnce() -> T, F: Send + 'static, T: Send + 'static
Spawns a new thread, and returns a join handle for it.
The child thread may outlive the parent (unless the parent thread is the main thread; the whole process is terminated when the main thread finishes). The join handle can be used to block on termination of the child thread, including recovering its panics.
Errors
Unlike the spawn
`spawnfree function, this method yields an
` free function, this method yields an
io::Result
`io::Result` to capture any failure to create the thread at
the OS level.
fn scoped<'a, T, F>(self, f: F) -> Result<JoinGuard<'a, T>> where T: Send + 'a, F: FnOnce() -> T, F: Send + 'a
: memory unsafe if destructor is avoided, see #24292
Spawns a new child thread that must be joined within a given
scope, and returns a JoinGuard
`JoinGuard`.
The join guard can be used to explicitly join the child thread (via
join
`join), returning
`), returning Result<T>
`Result
Errors
Unlike the scoped
`scopedfree function, this method yields an
` free function, this method yields an
io::Result
`io::Result` to capture any failure to create the thread at
the OS level.