check_if_cancelled

Macro check_if_cancelled 

Source
macro_rules! check_if_cancelled {
    ($state:expr) => { ... };
}
Expand description

Check if the task has been canceled and return None if it has. Can be used inside the worker function of a crate::CancelableWorker.

Can not be used with the crate::BasicWorker or crate::OrderedWorker.

§Example usage:

fn worker_function(task: T, state: &State) -> Option<R> {
    while work_not_done {
        check_if_cancelled!(state);   
        do_work();
    }
    Some(result)
}

§Shorthand for:

if state.is_cancelled() {
   return None;
}