Function thread_priority::spawn_scoped_careless

source ·
pub fn spawn_scoped_careless<'scope, 'env, F, T>(
    scope: &'scope Scope<'scope, 'env>,
    priority: ThreadPriority,
    f: F
) -> Result<ScopedJoinHandle<'scope, T>>
where F: FnOnce() -> T + Send + 'scope, T: Send + 'scope,
Expand description

Spawns a scoped thread with the specified priority. This is different from spawn_scoped in a way that the passed function doesn’t need to accept the ThreadPriority::set_for_current result. In case of an error, the error is logged using the logging facilities.

See spawn_scoped.

use thread_priority::*;

let x = 0;

std::thread::scope(|s| {
    spawn_scoped_careless(s, ThreadPriority::Max, || {
        // This is printed out from within the spawned thread.
        println!("We don't care about the priority result.");
        dbg!(&x);
    });
});