pub fn execute_task<F>(mut current_task: CurrentTask, task_complete: F)
where
    F: FnOnce(Result<i32, Error>) + Send + Sync + 'static,
{
    std::thread::spawn(move || {
        task_complete(|| -> Result<i32, Error> {
            let exceptions = start_task_thread(&current_task)?;
            // Unwrap the error because if we don't, we'll panic anyway from destroying the task
            // without having previous called sys_exit(), and that will swallow the actual error.
            Ok(run_exception_loop(&mut current_task, exceptions).unwrap())
        }());
    });
}
/// Spawns a thread that executes `current_task`.
///
/// The `current_task` is expected to be initialized before calling `execute_task`. This means
/// the process or thread associated with the task must have already been created, but not started.
///
/// # Parameters
/// - `current_task`: The task to start executing.
/// - `task_complete`: A function that is called when the task finishes executing. The result
///                    contains the exit code of the task.
Spawns a thread that executes `current_task`.
The `current_task` is expected to be initialized before calling `execute_task`. This means
the process or thread associated with the task must have already been created, but not started.
Spawns a thread that executes ` current_task ` . The ` current_task ` is expected to be initialized before calling ` execute_task ` . This means the process or thread associated with the task must have already been created but not started .
pub fn execute_task<F>(mut current_task: CurrentTask, task_complete: F)
where
    F: FnOnce(Result<i32, Error>) + Send + Sync + 'static,
{
    std::thread::spawn(move || {
        task_complete(|| -> Result<i32, Error> {
            let exceptions = start_task_thread(&current_task)?;
            // Unwrap the error because if we don't, we'll panic anyway from destroying the task
            // without having previous called sys_exit(), and that will swallow the actual error.
            Ok(run_exception_loop(&mut current_task, exceptions).unwrap())
        }());
    });
}
pub fn execute_task < F > ( mut current_task : CurrentTask , task_complete : F ) where F : FnOnce ( Result < i32 , Error > ) + Send + Sync + ' static , { std :: thread :: spawn ( move | | { task_complete ( | | -> Result < i32 , Error > { let exceptions = start_task_thread ( & current_task ) ? ; // Unwrap the error because if we don't, we'll panic anyway from destroying the task // without having previous called sys_exit(), and that will swallow the actual error. Ok ( run_exception_loop ( & mut current_task , exceptions ) . unwrap ( ) ) } ( ) ) ; } ) ; }
Spawns a thread that executes `current_task`.
Spawns a thread that executes ` current_task ` .
current_task
CurrentTask
task_complete
F
current_task
CurrentTask
The task to start executing.
The task to start executing .
task_complete
F
A function that is called when the task finishes executing. The result
contains the exit code of the task.
A function that is called when the task finishes executing . The result contains the exit code of the task .