Struct heron::rapier_plugin::rapier2d::crossbeam::thread::ScopedThreadBuilder[]

pub struct ScopedThreadBuilder<'scope, 'env> { /* fields omitted */ }
Expand description

Configures the properties of a new thread.

The two configurable properties are:

The spawn method will take ownership of the builder and return an io::Result of the thread handle with the given configuration.

The Scope::spawn method uses a builder with default configuration and unwraps its return value. You may want to use this builder when you want to recover from a failure to launch a thread.

Examples

use crossbeam_utils::thread;

thread::scope(|s| {
    s.builder()
        .spawn(|_| println!("Running a child thread"))
        .unwrap();
}).unwrap();

Implementations

Sets the name for the new thread.

The name must not contain null bytes (\0).

For more information about named threads, see here.

Examples
use crossbeam_utils::thread;
use std::thread::current;

thread::scope(|s| {
    s.builder()
        .name("my thread".to_string())
        .spawn(|_| assert_eq!(current().name(), Some("my thread")))
        .unwrap();
}).unwrap();

Sets the size of the stack for the new thread.

The stack size is measured in bytes.

For more information about the stack size for threads, see here.

Examples
use crossbeam_utils::thread;

thread::scope(|s| {
    s.builder()
        .stack_size(32 * 1024)
        .spawn(|_| println!("Running a child thread"))
        .unwrap();
}).unwrap();

Spawns a scoped thread with this configuration.

The scoped thread is passed a reference to this scope as an argument, which can be used for spawning nested threads.

The returned handle can be used to manually join the thread before the scope exits.

Errors

Unlike the Scope::spawn method, this method yields an io::Result to capture any failure to create the thread at the OS level.

Panics

Panics if a thread name was set and it contained null bytes.

Examples
use crossbeam_utils::thread;

thread::scope(|s| {
    let handle = s.builder()
        .spawn(|_| {
            println!("A child thread is running");
            42
        })
        .unwrap();

    // Join the thread and retrieve its result.
    let res = handle.join().unwrap();
    assert_eq!(res, 42);
}).unwrap();

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

The alignment of pointer.

The type for initializers.

Initializes a with the given initializer. Read more

Dereferences the given pointer. Read more

Mutably dereferences the given pointer. Read more

Drops the object pointed to by the given pointer. Read more

Should always be Self

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more

Checks if self is actually part of its subset T (and can be converted to it).

Use with care! Same as self.to_subset but without any property checks. Always succeeds.

The inclusion map: converts self to the equivalent element of its superset.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more