fn start_respawnable<F>(
    group: Arc<ThreadGroup>,
    records: &mut MutexGuard<GroupRecords>,
    name: Option<String>,
    task: Arc<F>,
) -> io::Result<()>
where
    F: Fn() + Send + Sync + 'static,
{
    records.thread_count += 1;
    let handle = RespawnableHandle {
        group,
        parent: thread::current().id(),
        task,
        last_start: Instant::now(),
    };
    let result = thread::Builder::new()
        .name(name.unwrap_or_else(|| "anonymous".to_owned()))
        .spawn(move || {
            (handle.task)();
            drop(handle);
        });
    if result.is_err() {
        records.thread_count -= 1;
    }
    result.and(Ok(()))
}
/// The implementation of respawnable thread creation.
The implementation of respawnable thread creation.
The implementation of respawnable thread creation .
fn start_respawnable<F>(
    group: Arc<ThreadGroup>,
    records: &mut MutexGuard<GroupRecords>,
    name: Option<String>,
    task: Arc<F>,
) -> io::Result<()>
where
    F: Fn() + Send + Sync + 'static,
{
    records.thread_count += 1;
    let handle = RespawnableHandle {
        group,
        parent: thread::current().id(),
        task,
        last_start: Instant::now(),
    };
    let result = thread::Builder::new()
        .name(name.unwrap_or_else(|| "anonymous".to_owned()))
        .spawn(move || {
            (handle.task)();
            drop(handle);
        });
    if result.is_err() {
        records.thread_count -= 1;
    }
    result.and(Ok(()))
}
fn start_respawnable < F > ( group : Arc < ThreadGroup > , records : & mut MutexGuard < GroupRecords > , name : Option < String > , task : Arc < F > , ) -> io :: Result < ( ) > where F : Fn ( ) + Send + Sync + ' static , { records . thread_count += 1 ; let handle = RespawnableHandle { group , parent : thread :: current ( ) . id ( ) , task , last_start : Instant :: now ( ) , } ; let result = thread :: Builder :: new ( ) . name ( name . unwrap_or_else ( | | " " . to_owned ( ) ) ) . spawn ( move | | { ( handle . task ) ( ) ; drop ( handle ) ; } ) ; if result . is_err ( ) { records . thread_count -= 1 ; } result . and ( Ok ( ( ) ) ) }
The implementation of respawnable thread creation.
The implementation of respawnable thread creation .
group
Arc<ThreadGroup>
records
&mut MutexGuard<GroupRecords>
name
Option<String>
task
Arc<F>
group
Arc<ThreadGroup>
records
&mut MutexGuard<GroupRecords>
name
Option<String>
task
Arc<F>